diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 0000000..271835b --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,25 @@ +name: Generate terraform docs + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.ref }} + + - name: Render terraform docs inside the README.md and push changes back to PR branch + uses: terraform-docs/gh-actions@v0.6.0 + with: + working-dir: . + output-file: README.md + output-method: inject + git-push: "true" diff --git a/CHANGELOG.md b/CHANGELOG.md index 49f00bb..bdc90e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## v4.0.0 +- BREAKING: remove Grafana from module +- NOTE: Before upgrade: `terraform state rm module.thanos.grafana_data_source.thanos` +- NOTE: Before upgrade: `terraform destroy -target=module.thanos.module.grafana` + + +## v3.0.1 +- Update variant to support discovering CF instances + ## v3.0.0 - Add [variant](https://github.com/philips-labs/variant) support - Rename cf_exporter_config to more generic cf_functional_account diff --git a/README.md b/README.md index a23c618..1c778ba 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ module "thanos" { cf_org_name = var.cf_org_name cf_space_name = var.cf_space_name - enable_grafana = true docker_username = var.cf_username docker_password = var.cf_password @@ -34,112 +33,82 @@ module "thanos" { PASSWORD = var.cf_password API_ENDPOINT = var.cf_api } - - // some Grafana env.vars - grafana_environment = { - GF_SECURITY_ADMIN_USER = test_user - GF_SECURITY_ADMIN_PASSWORD = test_pass - } } ``` - ## Requirements -| Name | Version | -| --------------------------------------------------------------------------------- | --------- | -| [terraform](#requirement_terraform) | >= 0.13.0 | -| [cloudfoundry](#requirement_cloudfoundry) | >= 0.14.2 | -| [grafana](#requirement_grafana) | >= 1.11.0 | -| [hsdp](#requirement_hsdp) | >= 0.16.3 | -| [random](#requirement_random) | >= 2.2.1 | +| Name | Version | +|------|---------| +| terraform | >= 0.13.0 | +| cloudfoundry | >= 0.14.2 | +| hsdp | >= 0.16.3 | +| random | >= 2.2.1 | ## Providers -| Name | Version | -| --------------------------------------------------------------------------- | --------- | -| [cloudfoundry](#provider_cloudfoundry) | >= 0.14.2 | -| [grafana](#provider_grafana) | >= 1.11.0 | -| [hsdp](#provider_hsdp) | >= 0.16.3 | -| [random](#provider_random) | >= 2.2.1 | +| Name | Version | +|------|---------| +| cloudfoundry | >= 0.14.2 | +| hsdp | >= 0.16.3 | +| random | >= 2.2.1 | ## Modules -| Name | Source | Version | -| -------------------------------------------------------- | --------------------------------- | ------- | -| [grafana](#module_grafana) | philips-labs/grafana/cloudfoundry | 0.9.0 | +No Modules. ## Resources -| Name | Type | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | -| [cloudfoundry_app.thanos](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/app) | resource | -| [cloudfoundry_app.thanos_query](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/app) | resource | -| [cloudfoundry_app.thanos_store](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/app) | resource | -| [cloudfoundry_network_policy.grafana_database_metrics](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/network_policy) | resource | -| [cloudfoundry_network_policy.thanos_query](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/network_policy) | resource | -| [cloudfoundry_network_policy.thanos_store](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/network_policy) | resource | -| [cloudfoundry_route.thanos](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/route) | resource | -| [cloudfoundry_route.thanos_internal](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/route) | resource | -| [cloudfoundry_route.thanos_query](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/route) | resource | -| [cloudfoundry_route.thanos_query_internal](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/route) | resource | -| [cloudfoundry_route.thanos_store_internal](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/route) | resource | -| [cloudfoundry_service_instance.s3](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/service_instance) | resource | -| [grafana_data_source.thanos](https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/data_source) | resource | -| [random_id.id](https://registry.terraform.io/providers/random/latest/docs/resources/id) | resource | -| [random_password.password](https://registry.terraform.io/providers/random/latest/docs/resources/password) | resource | -| [cloudfoundry_domain.app_domain](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/data-sources/domain) | data source | -| [cloudfoundry_domain.apps_internal_domain](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/data-sources/domain) | data source | -| [cloudfoundry_org.org](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/data-sources/org) | data source | -| [cloudfoundry_service.s3](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/data-sources/service) | data source | -| [hsdp_config.cf](https://registry.terraform.io/providers/philips-software/hsdp/latest/docs/data-sources/config) | data source | +| Name | +|------| +| [cloudfoundry_app](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/app) | +| [cloudfoundry_domain](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/data-sources/domain) | +| [cloudfoundry_network_policy](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/network_policy) | +| [cloudfoundry_org](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/data-sources/org) | +| [cloudfoundry_route](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/route) | +| [cloudfoundry_service](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/data-sources/service) | +| [cloudfoundry_service_instance](https://registry.terraform.io/providers/cloudfoundry-community/cloudfoundry/latest/docs/resources/service_instance) | +| [hsdp_config](https://registry.terraform.io/providers/philips-software/hsdp/latest/docs/data-sources/config) | +| [random_id](https://registry.terraform.io/providers/random/latest/docs/resources/id) | +| [random_password](https://registry.terraform.io/providers/random/latest/docs/resources/password) | ## Inputs -| Name | Description | Type | Default | Required | -| --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------- | :------: | -| [cf_exporter_config](#input_cf_exporter_config) | Configuration for the CloudFoundry exporter. Required if enable_cf_exporter is set to true |
object({
api_endpoint = string
username = string
password = string
})
|
{
"api_endpoint": "",
"password": "",
"username": ""
}
| no | -| [cf_org_name](#input_cf_org_name) | Cloudfoundry ORG name to use for reverse proxy | `string` | n/a | yes | -| [cf_space_id](#input_cf_space_id) | Cloudfoundry SPACE id to use for deploying all Thanos components. | `string` | n/a | yes | -| [docker_password](#input_docker_password) | Docker registry password | `string` | `""` | no | -| [docker_username](#input_docker_username) | Docker registry username | `string` | `""` | no | -| [enable_cf_exporter](#input_enable_cf_exporter) | Enable the CloudFoundry metrics exporter and scrape it from Thanos | `bool` | `false` | no | -| [environment](#input_environment) | Pass environment variable to the app | `map(any)` | `{}` | no | -| [grafana_environment](#input_grafana_environment) | Pass environment variable to Grafana | `map(any)` | `{}` | no | -| [grafana_image](#input_grafana_image) | Image to use for Grafana | `string` | `"grafana/grafana:latest"` | no | -| [grafana_password](#input_grafana_password) | Grafana password | `string` | n/a | yes | -| [grafana_public_endpoints](#input_grafana_public_endpoints) | Make Grafana public endpoint | `bool` | `true` | no | -| [grafana_username](#input_grafana_username) | Grafana username | `string` | `"admin"` | no | -| [name_postfix](#input_name_postfix) | The postfix string to append to the space, hostname, etc. Prevents namespace clashes | `string` | `""` | no | -| [thanos_disk_quota](#input_thanos_disk_quota) | Thanos disk quota | `number` | `5000` | no | -| [thanos_extra_config](#input_thanos_extra_config) | Any extra yaml config that will be merged into the prometheus config at runtime. Extra targets can be added here. | `string` | `""` | no | -| [thanos_file_sd_url](#input_thanos_file_sd_url) | A URL that exposes a prometheus file_sd yaml file will be periodically downloaded and used for service discovery | `string` | `""` | no | -| [thanos_image](#input_thanos_image) | Image to use for Thanos app. Use a v\* tagged version to prevent automatic updates | `string` | `"philipslabs/cf-thanos:v2.0.5"` | no | -| [thanos_memory](#input_thanos_memory) | Thanos memory | `number` | `1024` | no | -| [thanos_public_endpoints](#input_thanos_public_endpoints) | Make Thanos public endpoint | `bool` | `true` | no | -| [thanos_query_image](#input_thanos_query_image) | Image to use for Thanos query. Use a v\* tagged version to prevent automatic updates | `string` | `"philipslabs/cf-thanos:v2.0.5"` | no | -| [thanos_store_disk_quota](#input_thanos_store_disk_quota) | Thanos store disk quota | `number` | `5000` | no | -| [thanos_store_image](#input_thanos_store_image) | Image to use for Thanos store. Use a v\* tagged version to prevent automatic updates | `string` | `"philipslabs/cf-thanos:v2.0.5"` | no | -| [thanos_store_memory](#input_thanos_store_memory) | Thanos store memory | `number` | `1024` | no | +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| cf\_functional\_account | Configuration for the CloudFoundry function account. Required for variant and if enable\_cf\_exporter is set to true |
object({
api_endpoint = string
username = string
password = string
})
|
{
"api_endpoint": "",
"password": "",
"username": ""
}
| no | +| cf\_org\_name | Cloudfoundry ORG name to use for reverse proxy | `string` | n/a | yes | +| cf\_space\_id | Cloudfoundry SPACE id to use for deploying all Thanos components. | `string` | n/a | yes | +| docker\_password | Docker registry password | `string` | `""` | no | +| docker\_username | Docker registry username | `string` | `""` | no | +| enable\_cf\_exporter | Enable the CloudFoundry metrics exporter and scrape it from Thanos | `bool` | `false` | no | +| environment | Pass environment variable to the app | `map(any)` | `{}` | no | +| name\_postfix | The postfix string to append to the space, hostname, etc. Prevents namespace clashes | `string` | `""` | no | +| tenants | The list of tenants to scrape. When an app does not specify tenant then 'default' is used | `list(string)` |
[
"default"
]
| no | +| thanos\_disk\_quota | Thanos disk quota | `number` | `5000` | no | +| thanos\_extra\_config | Any extra yaml config that will be merged into the prometheus config at runtime. Extra targets can be added here. | `string` | `""` | no | +| thanos\_file\_sd\_url | A URL that exposes a prometheus file\_sd yaml file will be periodically downloaded and used for service discovery | `string` | `""` | no | +| thanos\_image | Image to use for Thanos app. Use a v* tagged version to prevent automatic updates | `string` | `"philipslabs/cf-thanos:v3.0.1"` | no | +| thanos\_memory | Thanos memory | `number` | `1024` | no | +| thanos\_public\_endpoints | Make Thanos public endpoint | `bool` | `false` | no | +| thanos\_query\_image | Image to use for Thanos query. Use a v* tagged version to prevent automatic updates | `string` | `"philipslabs/cf-thanos:v3.0.1"` | no | +| thanos\_store\_disk\_quota | Thanos store disk quota | `number` | `5000` | no | +| thanos\_store\_image | Image to use for Thanos store. Use a v* tagged version to prevent automatic updates | `string` | `"philipslabs/cf-thanos:v3.0.1"` | no | +| thanos\_store\_memory | Thanos store memory | `number` | `1024` | no | ## Outputs -| Name | Description | -| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- | -| [cluster_id](#output_cluster_id) | Cluster ID of Thanos deployment | -| [grafana_app_id](#output_grafana_app_id) | App id for Grafana | -| [grafana_auth](#output_grafana_auth) | The Grafana auth token to use for e.g. configuring Grafana provider | -| [grafana_endpoint](#output_grafana_endpoint) | URL of Grafana deployment (optional) | -| [grafana_url](#output_grafana_url) | The Grafana URL | -| [grafana_username](#output_grafana_username) | The Grafana username | -| [thanos_app_id](#output_thanos_app_id) | App id for Thanos | -| [thanos_endpoint](#output_thanos_endpoint) | URL of Thanos deployment | -| [thanos_query_app_id](#output_thanos_query_app_id) | App id for Thanos Query | -| [thanos_query_endpoint](#output_thanos_query_endpoint) | URL of Thanos query deployment | -| [thanos_space_id](#output_thanos_space_id) | Cloud foundry space ID of Thanos | -| [thanos_store_app_id](#output_thanos_store_app_id) | App id for Thanos Store | -| [thanos_store_endpoint](#output_thanos_store_endpoint) | Internal only URL of Thanos store deployment | +| Name | Description | +|------|-------------| +| postfix | Cluster ID / Postfix of Thanos deployment | +| thanos\_app\_id | App id for Thanos | +| thanos\_endpoint | URL of Thanos deployment | +| thanos\_query\_app\_id | App id for Thanos Query | +| thanos\_query\_endpoint | URL of Thanos query deployment | +| thanos\_space\_id | Cloud foundry space ID of Thanos | +| thanos\_store\_app\_id | App id for Thanos Store | +| thanos\_store\_endpoint | Internal only URL of Thanos store deployment | diff --git a/examples/default/main.tf b/examples/default/main.tf index 4031383..a984a74 100644 --- a/examples/default/main.tf +++ b/examples/default/main.tf @@ -4,11 +4,9 @@ module "thanos" { cf_org_name = "demo" cf_space_id = "test" - grafana_password = "password" - cf_functional_account = { api_endpoint = var.cf_api_url username = var.cf_username password = var.cf_password } -} \ No newline at end of file +} diff --git a/examples/default/providers.tf b/examples/default/providers.tf index f1c4339..3ea6834 100644 --- a/examples/default/providers.tf +++ b/examples/default/providers.tf @@ -5,11 +5,6 @@ provider "cloudfoundry" { skip_ssl_validation = false } -provider "grafana" { - url = "http://foo" - auth = "admin:password" -} - provider "hsdp" { region = "us-east" } diff --git a/examples/default/versions.tf b/examples/default/versions.tf index f42807f..ca2fadc 100644 --- a/examples/default/versions.tf +++ b/examples/default/versions.tf @@ -7,9 +7,5 @@ terraform { source = "philips-software/hsdp" version = ">= 0.17.0" } - grafana = { - source = "grafana/grafana" - version = ">= 1.11.0" - } } } diff --git a/grafana.tf b/grafana.tf deleted file mode 100644 index e1f4338..0000000 --- a/grafana.tf +++ /dev/null @@ -1,36 +0,0 @@ -module "grafana" { - source = "philips-labs/grafana/cloudfoundry" - version = "0.9.1" - - enable_postgres = true - grafana_image = var.grafana_image - grafana_username = var.grafana_username - grafana_password = var.grafana_password - cf_space_id = var.cf_space_id - cf_org = data.cloudfoundry_org.org.name - cf_domain = var.grafana_public_endpoints ? data.cloudfoundry_domain.app_domain.name : data.cloudfoundry_domain.apps_internal_domain.name - name_postfix = local.postfix - environment = var.grafana_environment - network_policies = [ - { - destination_app = cloudfoundry_app.thanos_query.id - protocol = "tcp" - port = "9090" - }, - { - destination_app = cloudfoundry_app.thanos_store.id - protocol = "tcp" - port = "9090" - } - ] -} - -resource "grafana_data_source" "thanos" { - name = "thanos" - type = "prometheus" - url = "${cloudfoundry_route.thanos_query_internal.endpoint}:9090" - access_mode = "proxy" - is_default = true - - depends_on = [module.grafana.grafana_endpoint] -} \ No newline at end of file diff --git a/main.tf b/main.tf index 8d6037d..68198e6 100644 --- a/main.tf +++ b/main.tf @@ -4,7 +4,7 @@ locals { } resource "random_id" "id" { - byte_length = 8 + byte_length = 4 } resource "random_password" "password" { @@ -35,7 +35,6 @@ resource "cloudfoundry_app" "thanos" { VARIANT_PROMETHEUS_CONFIG = "/sidecars/etc/prometheus.yml" VARIANT_TENANTS = join(",", var.tenants) VARIANT_RELOAD = "true" - PG_EXPORTERS = join(",", [module.grafana.grafana_database_metrics_endpoint]) }, var.environment) dynamic "routes" { diff --git a/outputs.tf b/outputs.tf index 829b985..282a2cf 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,9 +1,5 @@ -locals { - grafana_endpoint = join("", module.grafana.*.grafana_endpoint) -} - -output "cluster_id" { - description = "Cluster ID of Thanos deployment" +output "postfix" { + description = "Cluster ID / Postfix of Thanos deployment" value = local.postfix } @@ -41,29 +37,3 @@ output "thanos_store_endpoint" { description = "Internal only URL of Thanos store deployment" value = "${cloudfoundry_route.thanos_store_internal.endpoint}:9090" } - -output "grafana_app_id" { - description = "App id for Grafana" - value = join("", module.grafana.*.grafana_id) -} - -output "grafana_endpoint" { - description = "URL of Grafana deployment (optional)" - value = var.grafana_public_endpoints ? local.grafana_endpoint : "${local.grafana_endpoint}:3000" -} - -output "grafana_auth" { - description = "The Grafana auth token to use for e.g. configuring Grafana provider" - value = local.grafana_auth - sensitive = true -} - -output "grafana_username" { - description = "The Grafana username" - value = var.grafana_username -} - -output "grafana_url" { - description = "The Grafana URL" - value = local.grafana_url -} \ No newline at end of file diff --git a/providers.tf b/providers.tf deleted file mode 100644 index aae0e2f..0000000 --- a/providers.tf +++ /dev/null @@ -1,11 +0,0 @@ -# NOTE: usage of provider config in the module makes it incompatible with for_each, count, and depends_on -# Details available here: https://www.terraform.io/docs/language/modules/develop/providers.html -locals { - grafana_auth = "${var.grafana_username}:${var.grafana_password}" - grafana_url = "https://${local.grafana_endpoint}" -} - -provider "grafana" { - url = local.grafana_url - auth = local.grafana_auth -} \ No newline at end of file diff --git a/variables.tf b/variables.tf index 44a88b6..78d03e5 100644 --- a/variables.tf +++ b/variables.tf @@ -38,41 +38,12 @@ variable "thanos_public_endpoints" { default = false } -variable "grafana_username" { - description = "Grafana username" - type = string - default = "admin" -} - -variable "grafana_password" { - description = "Grafana password" - type = string -} - -variable "grafana_image" { - description = "Image to use for Grafana" - default = "grafana/grafana:8.0.4" - type = string -} - -variable "grafana_public_endpoints" { - description = "Make Grafana public endpoint" - type = bool - default = true -} - variable "environment" { type = map(any) description = "Pass environment variable to the app" default = {} } -variable "grafana_environment" { - type = map(any) - description = "Pass environment variable to Grafana" - default = {} -} - variable "docker_username" { type = string description = "Docker registry username" diff --git a/terraform.tf b/versions.tf similarity index 80% rename from terraform.tf rename to versions.tf index 3afab88..323c065 100644 --- a/terraform.tf +++ b/versions.tf @@ -10,10 +10,6 @@ terraform { source = "philips-software/hsdp" version = ">= 0.16.3" } - grafana = { - source = "grafana/grafana" - version = ">= 1.11.0" - } random = { source = "random" version = ">= 2.2.1"