From 822637f6bd5f3eb33a6f8ae90a2284d15f653aad Mon Sep 17 00:00:00 2001 From: Julien Duchesne Date: Wed, 22 May 2024 14:54:29 -0400 Subject: [PATCH] `grafana_cloud_stack`: Add `influx_url` Closes https://github.com/grafana/terraform-provider-grafana/issues/958 --- GNUmakefile | 2 +- docs/data-sources/cloud_stack.md | 1 + docs/resources/cloud_stack.md | 1 + internal/resources/cloud/resource_cloud_stack.go | 9 +++++++-- internal/resources/cloud/resource_cloud_stack_test.go | 1 + 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index d938d8f0b..f239fae2a 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,5 +1,5 @@ GRAFANA_VERSION ?= 11.0.0 -DOCKER_COMPOSE_ARGS ?= --force-recreate --detach --remove-orphans --wait +DOCKER_COMPOSE_ARGS ?= --force-recreate --detach --remove-orphans --wait --renew-anon-volumes testacc: TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m diff --git a/docs/data-sources/cloud_stack.md b/docs/data-sources/cloud_stack.md index cb3b03008..69e6f007f 100644 --- a/docs/data-sources/cloud_stack.md +++ b/docs/data-sources/cloud_stack.md @@ -45,6 +45,7 @@ available at “https://.grafana.net". - `graphite_url` (String) - `graphite_user_id` (Number) - `id` (String) The stack id assigned to this stack by Grafana. +- `influx_url` (String) Base URL of the InfluxDB instance configured for this stack. See https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-influxdb/push-from-telegraf/ for docs on how to use this. - `labels` (Map of String) A map of labels to assign to the stack. Label keys and values must match the following regexp: "^[a-zA-Z0-9/\\-.]+$" and stacks cannot have more than 10 labels. - `logs_name` (String) - `logs_status` (String) diff --git a/docs/resources/cloud_stack.md b/docs/resources/cloud_stack.md index 49e092439..439f11616 100644 --- a/docs/resources/cloud_stack.md +++ b/docs/resources/cloud_stack.md @@ -57,6 +57,7 @@ resource "grafana_cloud_stack" "test" { - `graphite_url` (String) - `graphite_user_id` (Number) - `id` (String) The stack id assigned to this stack by Grafana. +- `influx_url` (String) Base URL of the InfluxDB instance configured for this stack. See https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-influxdb/push-from-telegraf/ for docs on how to use this. - `logs_name` (String) - `logs_status` (String) - `logs_url` (String) diff --git a/internal/resources/cloud/resource_cloud_stack.go b/internal/resources/cloud/resource_cloud_stack.go index 14ce77f8f..187b095b6 100644 --- a/internal/resources/cloud/resource_cloud_stack.go +++ b/internal/resources/cloud/resource_cloud_stack.go @@ -177,8 +177,9 @@ Required access policy scopes: "graphite_url": common.ComputedString(), "graphite_status": common.ComputedString(), - // OTLP - "otlp_url": common.ComputedStringWithDescription("Base URL of the OTLP instance configured for this stack. See https://grafana.com/docs/grafana-cloud/send-data/otlp/send-data-otlp/ for docs on how to use this."), + // Connections + "influx_url": common.ComputedStringWithDescription("Base URL of the InfluxDB instance configured for this stack. See https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-influxdb/push-from-telegraf/ for docs on how to use this."), + "otlp_url": common.ComputedStringWithDescription("Base URL of the OTLP instance configured for this stack. See https://grafana.com/docs/grafana-cloud/send-data/otlp/send-data-otlp/ for docs on how to use this."), }, CustomizeDiff: customdiff.All( customdiff.ComputedIf("url", func(_ context.Context, diff *schema.ResourceDiff, meta interface{}) bool { @@ -419,6 +420,10 @@ func flattenStack(d *schema.ResourceData, stack *gcom.FormattedApiInstance, conn d.Set("otlp_url", otlpURL.Get()) } + if influxURL := connections.InfluxUrl; influxURL.IsSet() { + d.Set("influx_url", influxURL.Get()) + } + return nil } diff --git a/internal/resources/cloud/resource_cloud_stack_test.go b/internal/resources/cloud/resource_cloud_stack_test.go index dc918cbe4..dfbb87d1f 100644 --- a/internal/resources/cloud/resource_cloud_stack_test.go +++ b/internal/resources/cloud/resource_cloud_stack_test.go @@ -51,6 +51,7 @@ func TestResourceStack_Basic(t *testing.T) { resource.TestCheckResourceAttrSet("grafana_cloud_stack.test", "profiles_url"), resource.TestCheckResourceAttrSet("grafana_cloud_stack.test", "profiles_status"), resource.TestCheckResourceAttrSet("grafana_cloud_stack.test", "otlp_url"), + resource.TestCheckResourceAttrSet("grafana_cloud_stack.test", "influx_url"), ) resource.ParallelTest(t, resource.TestCase{