@@ -60,6 +60,53 @@ func TestAccGrafanaServiceAccountFromCloud(t *testing.T) {
60
60
})
61
61
}
62
62
63
+ // Tests that the ID change from 2.13.0 to latest works
64
+ // Remove on next major release
65
+ func TestAccGrafanaServiceAccountFromCloud_MigrateFrom213 (t * testing.T ) {
66
+ testutils .CheckCloudAPITestsEnabled (t )
67
+
68
+ var stack gcom.FormattedApiInstance
69
+ prefix := "tfsa213test"
70
+ slug := GetRandomStackName (prefix )
71
+
72
+ check := resource .ComposeTestCheckFunc (
73
+ testAccStackCheckExists ("grafana_cloud_stack.test" , & stack ),
74
+ testAccGrafanaAuthCheckServiceAccounts (& stack , []string {"management-sa" }),
75
+ resource .TestCheckResourceAttr ("grafana_cloud_stack_service_account.management" , "name" , "management-sa" ),
76
+ resource .TestCheckResourceAttr ("grafana_cloud_stack_service_account.management" , "role" , "Admin" ),
77
+ resource .TestCheckResourceAttr ("grafana_cloud_stack_service_account.management" , "is_disabled" , "true" ),
78
+ resource .TestCheckResourceAttr ("grafana_cloud_stack_service_account_token.management_token" , "name" , "management-sa-token" ),
79
+ resource .TestCheckNoResourceAttr ("grafana_cloud_stack_service_account_token.management_token" , "expiration" ),
80
+ resource .TestCheckResourceAttrSet ("grafana_cloud_stack_service_account_token.management_token" , "key" ),
81
+ )
82
+
83
+ resource .ParallelTest (t , resource.TestCase {
84
+ PreCheck : func () {
85
+ testAccDeleteExistingStacks (t , prefix )
86
+ },
87
+ CheckDestroy : testAccStackCheckDestroy (& stack ),
88
+ Steps : []resource.TestStep {
89
+ // Apply with 2.13.0 provider
90
+ {
91
+ Config : testAccGrafanaServiceAccountFromCloud (slug , slug , true ),
92
+ ExternalProviders : map [string ]resource.ExternalProvider {
93
+ "grafana" : {
94
+ VersionConstraint : "=2.13.0" ,
95
+ Source : "grafana/grafana" ,
96
+ },
97
+ },
98
+ Check : check ,
99
+ },
100
+ // Apply with latest provider
101
+ {
102
+ Config : testAccGrafanaServiceAccountFromCloud (slug , slug , true ),
103
+ Check : check ,
104
+ ProtoV5ProviderFactories : testutils .ProtoV5ProviderFactories ,
105
+ },
106
+ },
107
+ })
108
+ }
109
+
63
110
func testAccGrafanaServiceAccountFromCloud (name , slug string , disabled bool ) string {
64
111
return testAccStackConfigBasic (name , slug , "description" ) + fmt .Sprintf (`
65
112
resource "grafana_cloud_stack_service_account" "management" {
0 commit comments