@@ -105,6 +105,70 @@ func TestAccScalewayIamApiKey_WithApplication(t *testing.T) {
105
105
})
106
106
}
107
107
108
+ func TestAccScalewayIamApiKey_WithApplicationChange (t * testing.T ) {
109
+ tt := NewTestTools (t )
110
+ defer tt .Cleanup ()
111
+ resource .ParallelTest (t , resource.TestCase {
112
+ ProviderFactories : tt .ProviderFactories ,
113
+ CheckDestroy : resource .ComposeTestCheckFunc (
114
+ testAccCheckScalewayIamAPIKeyDestroy (tt ),
115
+ testAccCheckScalewayIamApplicationDestroy (tt ),
116
+ ),
117
+ Steps : []resource.TestStep {
118
+ {
119
+ Config : `
120
+ resource "scaleway_iam_application" "main" {
121
+ name = "tf_tests_api_key_app_change"
122
+ }
123
+
124
+ resource "scaleway_iam_application" "main2" {
125
+ name = "tf_tests_api_key_app_change2"
126
+ }
127
+
128
+ resource "scaleway_iam_api_key" "main" {
129
+ application_id = scaleway_iam_application.main.id
130
+ description = "tf_tests_with_application_change"
131
+ }
132
+ ` ,
133
+ Check : resource .ComposeTestCheckFunc (
134
+ testAccCheckScalewayIamAPIKeyExists (tt , "scaleway_iam_api_key.main" ),
135
+ resource .TestCheckResourceAttrPair ("scaleway_iam_api_key.main" , "application_id" , "scaleway_iam_application.main" , "id" ),
136
+ resource .TestCheckResourceAttr ("scaleway_iam_api_key.main" , "description" , "tf_tests_with_application_change" ),
137
+ resource .TestCheckResourceAttrSet ("scaleway_iam_api_key.main" , "secret_key" ),
138
+ ),
139
+ },
140
+ {
141
+ Config : `
142
+ resource "scaleway_iam_application" "main" {
143
+ name = "tf_tests_api_key_app_change"
144
+ }
145
+
146
+ resource "scaleway_iam_application" "main2" {
147
+ name = "tf_tests_api_key_app_change2"
148
+ }
149
+
150
+ resource "scaleway_iam_api_key" "main" {
151
+ application_id = scaleway_iam_application.main2.id
152
+ description = "tf_tests_with_application_change"
153
+ }
154
+ ` ,
155
+ Check : resource .ComposeTestCheckFunc (
156
+ testAccCheckScalewayIamAPIKeyExists (tt , "scaleway_iam_api_key.main" ),
157
+ resource .TestCheckResourceAttrPair ("scaleway_iam_api_key.main" , "application_id" , "scaleway_iam_application.main2" , "id" ),
158
+ resource .TestCheckResourceAttr ("scaleway_iam_api_key.main" , "description" , "tf_tests_with_application_change" ),
159
+ resource .TestCheckResourceAttrSet ("scaleway_iam_api_key.main" , "secret_key" ),
160
+ ),
161
+ },
162
+ {
163
+ ResourceName : "scaleway_iam_api_key.main" ,
164
+ ImportState : true ,
165
+ ImportStateVerify : true ,
166
+ ImportStateVerifyIgnore : []string {"secret_key" },
167
+ },
168
+ },
169
+ })
170
+ }
171
+
108
172
func TestAccScalewayIamApiKey_Expires (t * testing.T ) {
109
173
tt := NewTestTools (t )
110
174
defer tt .Cleanup ()
0 commit comments