Skip to content

Commit 0c0dbb1

Browse files
Cloud Stack: Fix read on existing slacks (#449)
* Cloud Stack: Fix read on existing slacks Fixes #448 Bumping the client to grafana/grafana-api-golang-client#76 does it Also, I found an import issue on the cloud stacks while testing this. I added an import test * Uncomment to test fix * Remove space * Try new fix * Clearer message * Update grafana/resource_cloud_stack.go Co-authored-by: Leandro López <[email protected]> Co-authored-by: Leandro López <[email protected]>
1 parent 7746885 commit 0c0dbb1

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
require (
66
github.com/Masterminds/semver/v3 v3.1.1
7-
github.com/grafana/grafana-api-golang-client v0.5.0
7+
github.com/grafana/grafana-api-golang-client v0.5.1
88
github.com/grafana/machine-learning-go-client v0.1.1
99
github.com/grafana/synthetic-monitoring-agent v0.8.0
1010
github.com/grafana/synthetic-monitoring-api-go-client v0.6.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8
113113
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
114114
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
115115
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
116-
github.com/grafana/grafana-api-golang-client v0.5.0 h1:wLb8izoz4rEtgwpD6ORDmpqWnKoLUzGspFjX1n1e00o=
117-
github.com/grafana/grafana-api-golang-client v0.5.0/go.mod h1:24W29gPe9yl0/3A9X624TPkAOR8DpHno490cPwnkv8E=
116+
github.com/grafana/grafana-api-golang-client v0.5.1 h1:PsYNB9mZ2LBC348eciPnU2y5lMqsQg6nANbBEAgG+Po=
117+
github.com/grafana/grafana-api-golang-client v0.5.1/go.mod h1:24W29gPe9yl0/3A9X624TPkAOR8DpHno490cPwnkv8E=
118118
github.com/grafana/machine-learning-go-client v0.1.1 h1:Gw6cX8xAd6IVF2LApkXOIdBK8Gzz07B3jQPukecw7fc=
119119
github.com/grafana/machine-learning-go-client v0.1.1/go.mod h1:QFfZz8NkqVF8++skjkKQXJEZfpCYd8S0yTWJUpsLLTA=
120120
github.com/grafana/synthetic-monitoring-agent v0.8.0 h1:X2fMX8J9SKLk9g4jvnNOmMsv0zFOjRP5Rv6f1TGMVzI=

grafana/resource_cloud_stack.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ Changing region will destroy the existing stack and create a new one in the desi
8080
Optional: true,
8181
Default: true,
8282
Description: "Whether to wait for readiness of the stack after creating it. The check is a HEAD request to the stack URL (Grafana instance).",
83+
// Suppress the diff if the new value is "false" because this attribute is only used at creation-time
84+
// If the diff is suppress for a "true" value, the attribute cannot be read at all
85+
DiffSuppressFunc: func(_, _, newValue string, _ *schema.ResourceData) bool { return newValue == "false" },
8386
},
8487
"org_id": {
8588
Type: schema.TypeInt,
@@ -264,6 +267,9 @@ func ReadStack(ctx context.Context, d *schema.ResourceData, meta interface{}) di
264267
}
265268

266269
FlattenStack(d, stack)
270+
// Always set the wait attribute to true after creation
271+
// It no longer matters and this will prevent drift if the stack was imported
272+
d.Set("wait_for_readiness", true)
267273

268274
return nil
269275
}

grafana/resource_cloud_stack_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ func TestResourceCloudStack_Basic(t *testing.T) {
6666
resource.TestCheckResourceAttr("grafana_cloud_stack.test", "status", "active"),
6767
),
6868
},
69+
{
70+
ResourceName: "grafana_cloud_stack.test",
71+
ImportState: true,
72+
ImportStateVerify: true,
73+
},
6974
},
7075
})
7176
}

0 commit comments

Comments
 (0)