@@ -55,6 +55,7 @@ func TestAccTransferWebApp_basic(t *testing.T) {
55
55
statecheck .ExpectKnownValue (resourceName , tfjsonpath .New ("access_endpoint" ), knownvalue .StringRegexp (regexache .MustCompile (`^https:\/\/.*.aws$` ))),
56
56
statecheck .ExpectKnownValue (resourceName , tfjsonpath .New (names .AttrARN ), tfknownvalue .RegionalARNRegexp ("transfer" , regexache .MustCompile (`webapp/.+` ))),
57
57
statecheck .ExpectKnownValue (resourceName , tfjsonpath .New (names .AttrTags ), knownvalue .Null ()),
58
+ statecheck .ExpectKnownValue (resourceName , tfjsonpath .New ("web_app_endpoint_policy" ), tfknownvalue .StringExact (awstypes .WebAppEndpointPolicyStandard )),
58
59
statecheck .ExpectKnownValue (resourceName , tfjsonpath .New ("web_app_units" ), knownvalue .ListExact ([]knownvalue.Check {
59
60
knownvalue .ObjectExact (map [string ]knownvalue.Check {
60
61
"provisioned" : knownvalue .Int64Exact (1 ),
@@ -185,11 +186,9 @@ func TestAccTransferWebApp_tags(t *testing.T) {
185
186
})
186
187
}
187
188
188
- /*
189
189
func TestAccTransferWebApp_webAppUnits (t * testing.T ) {
190
190
ctx := acctest .Context (t )
191
-
192
- var webappBefore, webappAfter awstypes.DescribedWebApp
191
+ var v awstypes.DescribedWebApp
193
192
rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
194
193
resourceName := "aws_transfer_web_app.test"
195
194
@@ -204,65 +203,55 @@ func TestAccTransferWebApp_webAppUnits(t *testing.T) {
204
203
CheckDestroy : testAccCheckWebAppDestroy (ctx ),
205
204
Steps : []resource.TestStep {
206
205
{
207
- Config: testAccWebAppConfig_webAppUnits(rName, 1 ),
206
+ Config : testAccWebAppConfig_webAppUnits (rName , 2 ),
208
207
Check : resource .ComposeAggregateTestCheckFunc (
209
- testAccCheckWebAppExists(ctx, resourceName, &webappBefore),
210
- resource.TestCheckResourceAttr(resourceName, "identity_provider_details.#", "1"),
211
- resource.TestCheckResourceAttr(resourceName, "identity_provider_details.0.identity_center_config.#", "1"),
212
- resource.TestCheckResourceAttrPair(resourceName, "identity_provider_details.0.identity_center_config.0.instance_arn", "data.aws_ssoadmin_instances.test", "arns.0"),
213
- resource.TestCheckResourceAttrPair(resourceName, "identity_provider_details.0.identity_center_config.0.role", "aws_iam_role.test", names.AttrARN),
214
- resource.TestCheckResourceAttr(resourceName, "web_app_units.#", "1"),
215
- resource.TestCheckResourceAttr(resourceName, "web_app_units.0.provisioned", "1"),
216
- resource.TestCheckResourceAttr(resourceName, "web_app_endpoint_policy", "STANDARD"),
217
- resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, "1"),
218
- resource.TestCheckResourceAttr(resourceName, "tags.Name", rName),
208
+ testAccCheckWebAppExists (ctx , resourceName , & v ),
219
209
),
210
+ ConfigPlanChecks : resource.ConfigPlanChecks {
211
+ PreApply : []plancheck.PlanCheck {
212
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionCreate ),
213
+ },
214
+ },
215
+ ConfigStateChecks : []statecheck.StateCheck {
216
+ statecheck .ExpectKnownValue (resourceName , tfjsonpath .New ("web_app_units" ), knownvalue .ListExact ([]knownvalue.Check {
217
+ knownvalue .ObjectExact (map [string ]knownvalue.Check {
218
+ "provisioned" : knownvalue .Int64Exact (2 ),
219
+ }),
220
+ })),
221
+ },
220
222
},
221
223
{
222
- ResourceName: resourceName,
223
- ImportState: true,
224
- ImportStateVerify: true,
225
- },
226
- {
227
- Config: testAccWebAppConfig_webAppUnits(rName, 2),
228
- Check: resource.ComposeAggregateTestCheckFunc(
229
- testAccCheckWebAppExists(ctx, resourceName, &webappAfter),
230
- testAccCheckWebAppNotRecreated(&webappBefore, &webappAfter),
231
- resource.TestCheckResourceAttr(resourceName, "identity_provider_details.#", "1"),
232
- resource.TestCheckResourceAttr(resourceName, "identity_provider_details.0.identity_center_config.#", "1"),
233
- resource.TestCheckResourceAttrPair(resourceName, "identity_provider_details.0.identity_center_config.0.instance_arn", "data.aws_ssoadmin_instances.test", "arns.0"),
234
- resource.TestCheckResourceAttrPair(resourceName, "identity_provider_details.0.identity_center_config.0.role", "aws_iam_role.test", names.AttrARN),
235
- resource.TestCheckResourceAttr(resourceName, "web_app_units.#", "1"),
236
- resource.TestCheckResourceAttr(resourceName, "web_app_units.0.provisioned", "2"),
237
- resource.TestCheckResourceAttr(resourceName, "web_app_endpoint_policy", "STANDARD"),
238
- resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, "1"),
239
- resource.TestCheckResourceAttr(resourceName, "tags.Name", rName),
240
- ),
224
+ ResourceName : resourceName ,
225
+ ImportState : true ,
226
+ ImportStateVerify : true ,
227
+ ImportStateVerifyIdentifierAttribute : "web_app_id" ,
228
+ ImportStateIdFunc : acctest .AttrImportStateIdFunc (resourceName , "web_app_id" ),
241
229
},
242
230
{
243
- Config: testAccWebAppConfig_basic (rName, rName ),
231
+ Config : testAccWebAppConfig_webAppUnits (rName , 4 ),
244
232
Check : resource .ComposeAggregateTestCheckFunc (
245
- testAccCheckWebAppExists(ctx, resourceName, &webappAfter),
246
- testAccCheckWebAppNotRecreated(&webappBefore, &webappAfter),
247
- resource.TestCheckResourceAttr(resourceName, "identity_provider_details.#", "1"),
248
- resource.TestCheckResourceAttr(resourceName, "identity_provider_details.0.identity_center_config.#", "1"),
249
- resource.TestCheckResourceAttrPair(resourceName, "identity_provider_details.0.identity_center_config.0.instance_arn", "data.aws_ssoadmin_instances.test", "arns.0"),
250
- resource.TestCheckResourceAttrPair(resourceName, "identity_provider_details.0.identity_center_config.0.role", "aws_iam_role.test", names.AttrARN),
251
- resource.TestCheckResourceAttr(resourceName, "web_app_units.#", "1"),
252
- resource.TestCheckResourceAttr(resourceName, "web_app_units.0.provisioned", "2"),
253
- resource.TestCheckResourceAttr(resourceName, "web_app_endpoint_policy", "STANDARD"),
254
- resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, "1"),
255
- resource.TestCheckResourceAttr(resourceName, "tags.Name", rName),
233
+ testAccCheckWebAppExists (ctx , resourceName , & v ),
256
234
),
235
+ ConfigPlanChecks : resource.ConfigPlanChecks {
236
+ PreApply : []plancheck.PlanCheck {
237
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionUpdate ),
238
+ },
239
+ },
240
+ ConfigStateChecks : []statecheck.StateCheck {
241
+ statecheck .ExpectKnownValue (resourceName , tfjsonpath .New ("web_app_units" ), knownvalue .ListExact ([]knownvalue.Check {
242
+ knownvalue .ObjectExact (map [string ]knownvalue.Check {
243
+ "provisioned" : knownvalue .Int64Exact (4 ),
244
+ }),
245
+ })),
246
+ },
257
247
},
258
248
},
259
249
})
260
250
}
261
251
262
252
func TestAccTransferWebApp_accessEndpoint (t * testing.T ) {
263
253
ctx := acctest .Context (t )
264
-
265
- var webappBefore, webappAfter awstypes.DescribedWebApp
254
+ var v awstypes.DescribedWebApp
266
255
rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
267
256
resourceName := "aws_transfer_web_app.test"
268
257
@@ -279,62 +268,41 @@ func TestAccTransferWebApp_accessEndpoint(t *testing.T) {
279
268
{
280
269
Config : testAccWebAppConfig_accessEndPoint (rName , "https://example.com" ),
281
270
Check : resource .ComposeAggregateTestCheckFunc (
282
- testAccCheckWebAppExists(ctx, resourceName, &webappBefore),
283
- resource.TestCheckResourceAttr(resourceName, "access_endpoint", "https://example.com"),
284
- resource.TestCheckResourceAttr(resourceName, "identity_provider_details.#", "1"),
285
- resource.TestCheckResourceAttr(resourceName, "identity_provider_details.0.identity_center_config.#", "1"),
286
- resource.TestCheckResourceAttrPair(resourceName, "identity_provider_details.0.identity_center_config.0.instance_arn", "data.aws_ssoadmin_instances.test", "arns.0"),
287
- resource.TestCheckResourceAttrPair(resourceName, "identity_provider_details.0.identity_center_config.0.role", "aws_iam_role.test", names.AttrARN),
288
- resource.TestCheckResourceAttr(resourceName, "web_app_units.#", "1"),
289
- resource.TestCheckResourceAttr(resourceName, "web_app_units.0.provisioned", "1"),
290
- resource.TestCheckResourceAttr(resourceName, "web_app_endpoint_policy", "STANDARD"),
291
- resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, "1"),
292
- resource.TestCheckResourceAttr(resourceName, "tags.Name", rName),
271
+ testAccCheckWebAppExists (ctx , resourceName , & v ),
293
272
),
273
+ ConfigPlanChecks : resource.ConfigPlanChecks {
274
+ PreApply : []plancheck.PlanCheck {
275
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionCreate ),
276
+ },
277
+ },
278
+ ConfigStateChecks : []statecheck.StateCheck {
279
+ statecheck .ExpectKnownValue (resourceName , tfjsonpath .New ("access_endpoint" ), knownvalue .StringExact ("https://example.com" )),
280
+ },
294
281
},
295
282
{
296
- ResourceName: resourceName,
297
- ImportState: true,
298
- ImportStateVerify: true,
299
- },
300
- {
301
- Config: testAccWebAppConfig_accessEndPoint(rName, "https://example2.com"),
302
- Check: resource.ComposeAggregateTestCheckFunc(
303
- testAccCheckWebAppExists(ctx, resourceName, &webappAfter),
304
- testAccCheckWebAppNotRecreated(&webappBefore, &webappAfter),
305
- resource.TestCheckResourceAttr(resourceName, "access_endpoint", "https://example2.com"),
306
- resource.TestCheckResourceAttr(resourceName, "identity_provider_details.#", "1"),
307
- resource.TestCheckResourceAttr(resourceName, "identity_provider_details.0.identity_center_config.#", "1"),
308
- resource.TestCheckResourceAttrPair(resourceName, "identity_provider_details.0.identity_center_config.0.instance_arn", "data.aws_ssoadmin_instances.test", "arns.0"),
309
- resource.TestCheckResourceAttrPair(resourceName, "identity_provider_details.0.identity_center_config.0.role", "aws_iam_role.test", names.AttrARN),
310
- resource.TestCheckResourceAttr(resourceName, "web_app_units.#", "1"),
311
- resource.TestCheckResourceAttr(resourceName, "web_app_units.0.provisioned", "1"),
312
- resource.TestCheckResourceAttr(resourceName, "web_app_endpoint_policy", "STANDARD"),
313
- resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, "1"),
314
- resource.TestCheckResourceAttr(resourceName, "tags.Name", rName),
315
- ),
283
+ ResourceName : resourceName ,
284
+ ImportState : true ,
285
+ ImportStateVerify : true ,
286
+ ImportStateVerifyIdentifierAttribute : "web_app_id" ,
287
+ ImportStateIdFunc : acctest .AttrImportStateIdFunc (resourceName , "web_app_id" ),
316
288
},
317
289
{
318
- Config: testAccWebAppConfig_basic (rName, rName ),
290
+ Config : testAccWebAppConfig_accessEndPoint (rName , "https://example.net" ),
319
291
Check : resource .ComposeAggregateTestCheckFunc (
320
- testAccCheckWebAppExists(ctx, resourceName, &webappAfter),
321
- testAccCheckWebAppNotRecreated(&webappBefore, &webappAfter),
322
- resource.TestCheckResourceAttr(resourceName, "access_endpoint", "https://example2.com"),
323
- resource.TestCheckResourceAttr(resourceName, "identity_provider_details.#", "1"),
324
- resource.TestCheckResourceAttr(resourceName, "identity_provider_details.0.identity_center_config.#", "1"),
325
- resource.TestCheckResourceAttrPair(resourceName, "identity_provider_details.0.identity_center_config.0.instance_arn", "data.aws_ssoadmin_instances.test", "arns.0"),
326
- resource.TestCheckResourceAttrPair(resourceName, "identity_provider_details.0.identity_center_config.0.role", "aws_iam_role.test", names.AttrARN),
327
- resource.TestCheckResourceAttr(resourceName, "web_app_units.#", "1"),
328
- resource.TestCheckResourceAttr(resourceName, "web_app_units.0.provisioned", "1"),
329
- resource.TestCheckResourceAttr(resourceName, "web_app_endpoint_policy", "STANDARD"),
330
- resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, "1"),
331
- resource.TestCheckResourceAttr(resourceName, "tags.Name", rName),
292
+ testAccCheckWebAppExists (ctx , resourceName , & v ),
332
293
),
294
+ ConfigPlanChecks : resource.ConfigPlanChecks {
295
+ PreApply : []plancheck.PlanCheck {
296
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionUpdate ),
297
+ },
298
+ },
299
+ ConfigStateChecks : []statecheck.StateCheck {
300
+ statecheck .ExpectKnownValue (resourceName , tfjsonpath .New ("access_endpoint" ), knownvalue .StringExact ("https://example.net" )),
301
+ },
333
302
},
334
303
},
335
304
})
336
305
}
337
- */
338
306
339
307
func testAccCheckWebAppDestroy (ctx context.Context ) resource.TestCheckFunc {
340
308
return func (s * terraform.State ) error {
0 commit comments