@@ -16,6 +16,7 @@ import (
16
16
awstypes "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types"
17
17
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
18
18
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
19
+ "github.com/hashicorp/terraform-plugin-testing/plancheck"
19
20
"github.com/hashicorp/terraform-plugin-testing/terraform"
20
21
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
21
22
"github.com/hashicorp/terraform-provider-aws/internal/conns"
@@ -1260,6 +1261,7 @@ func TestAccELBV2TargetGroup_Stickiness_defaultNLB(t *testing.T) {
1260
1261
func TestAccELBV2TargetGroup_Stickiness_invalidALB (t * testing.T ) {
1261
1262
ctx := acctest .Context (t )
1262
1263
rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
1264
+ resourceName := "aws_lb_target_group.test"
1263
1265
1264
1266
resource .ParallelTest (t , resource.TestCase {
1265
1267
PreCheck : func () { acctest .PreCheck (ctx , t ) },
@@ -1288,9 +1290,13 @@ func TestAccELBV2TargetGroup_Stickiness_invalidALB(t *testing.T) {
1288
1290
ExpectError : regexache .MustCompile ("You cannot enable stickiness on target groups with the TLS protocol" ),
1289
1291
},
1290
1292
{
1291
- Config : testAccTargetGroupConfig_stickinessValidity (rName , "TCP_UDP" , "lb_cookie" , false , "round_robin" ),
1292
- PlanOnly : true ,
1293
- ExpectNonEmptyPlan : true ,
1293
+ Config : testAccTargetGroupConfig_stickinessValidity (rName , "TCP_UDP" , "lb_cookie" , false , "round_robin" ),
1294
+ ConfigPlanChecks : resource.ConfigPlanChecks {
1295
+ PreApply : []plancheck.PlanCheck {
1296
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionReplace ),
1297
+ },
1298
+ },
1299
+ ExpectError : regexache .MustCompile ("Stickiness type 'lb_cookie' is not supported for target groups with" ),
1294
1300
},
1295
1301
},
1296
1302
})
@@ -3716,7 +3722,7 @@ func TestAccELBV2TargetGroup_Instance_protocolVersion_MigrateV0(t *testing.T) {
3716
3722
Config : testAccTargetGroupConfig_Instance_protocolVersion (protocol , "HTTP1" ),
3717
3723
PreCheck : preCheck ,
3718
3724
PostCheck : postCheck ,
3719
- }.Steps (),
3725
+ }.Steps (resourceName ),
3720
3726
})
3721
3727
})
3722
3728
}
@@ -3788,7 +3794,7 @@ func TestAccELBV2TargetGroup_Lambda_defaults_MigrateV0(t *testing.T) {
3788
3794
resource .TestCheckResourceAttr (resourceName , "health_check.#" , "1" ),
3789
3795
resource .TestCheckResourceAttr (resourceName , "health_check.0.enabled" , acctest .CtFalse ),
3790
3796
),
3791
- }.Steps (),
3797
+ }.Steps (resourceName ),
3792
3798
})
3793
3799
}
3794
3800
@@ -3840,7 +3846,7 @@ func TestAccELBV2TargetGroup_Lambda_vpc_MigrateV0(t *testing.T) {
3840
3846
resource .TestCheckResourceAttr (resourceName , "target_type" , string (awstypes .TargetTypeEnumLambda )),
3841
3847
resource .TestCheckResourceAttr (resourceName , names .AttrVPCID , "" ), // Should be Null
3842
3848
),
3843
- }.Steps (),
3849
+ }.Steps (resourceName ),
3844
3850
})
3845
3851
}
3846
3852
@@ -3906,7 +3912,7 @@ func TestAccELBV2TargetGroup_Lambda_protocol_MigrateV0(t *testing.T) {
3906
3912
resource .TestCheckResourceAttr (resourceName , "target_type" , string (awstypes .TargetTypeEnumLambda )),
3907
3913
resource .TestCheckResourceAttr (resourceName , names .AttrProtocol , "" ), // Should be Null
3908
3914
),
3909
- }.Steps (),
3915
+ }.Steps (resourceName ),
3910
3916
})
3911
3917
})
3912
3918
}
@@ -3960,7 +3966,7 @@ func TestAccELBV2TargetGroup_Lambda_protocolVersion_MigrateV0(t *testing.T) {
3960
3966
resource .TestCheckResourceAttr (resourceName , "target_type" , string (awstypes .TargetTypeEnumLambda )),
3961
3967
resource .TestCheckNoResourceAttr (resourceName , "protocol_version" ),
3962
3968
),
3963
- }.Steps (),
3969
+ }.Steps (resourceName ),
3964
3970
})
3965
3971
}
3966
3972
@@ -4012,7 +4018,7 @@ func TestAccELBV2TargetGroup_Lambda_port_MigrateV0(t *testing.T) {
4012
4018
resource .TestCheckResourceAttr (resourceName , "target_type" , string (awstypes .TargetTypeEnumLambda )),
4013
4019
resource .TestCheckResourceAttr (resourceName , names .AttrPort , "0" ), // Should be Null
4014
4020
),
4015
- }.Steps (),
4021
+ }.Steps (resourceName ),
4016
4022
})
4017
4023
}
4018
4024
@@ -4088,7 +4094,7 @@ func TestAccELBV2TargetGroup_Lambda_HealthCheck_basic_MigrateV0(t *testing.T) {
4088
4094
resource .TestCheckResourceAttr (resourceName , "health_check.0.timeout" , "35" ),
4089
4095
resource .TestCheckResourceAttr (resourceName , "health_check.0.unhealthy_threshold" , "3" ),
4090
4096
),
4091
- }.Steps (),
4097
+ }.Steps (resourceName ),
4092
4098
})
4093
4099
}
4094
4100
@@ -4203,6 +4209,11 @@ func TestAccELBV2TargetGroup_Lambda_HealthCheck_protocol_MigrateV0(t *testing.T)
4203
4209
resource .TestCheckResourceAttr (resourceName , "health_check.0.enabled" , acctest .CtTrue ),
4204
4210
resource .TestCheckResourceAttr (resourceName , "health_check.0.protocol" , "" ),
4205
4211
)
4212
+ step .ConfigPlanChecks = resource.ConfigPlanChecks {
4213
+ PreApply : []plancheck.PlanCheck {
4214
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionCreate ),
4215
+ },
4216
+ }
4206
4217
} else {
4207
4218
t .Fatal ("invalid test case, one of invalidHealthCheckProtocol or warning must be set" )
4208
4219
}
@@ -4217,8 +4228,15 @@ func TestAccELBV2TargetGroup_Lambda_HealthCheck_protocol_MigrateV0(t *testing.T)
4217
4228
VersionConstraint : "5.26.0" ,
4218
4229
},
4219
4230
},
4220
- Config : config ,
4221
- PlanOnly : true ,
4231
+ Config : config ,
4232
+ ConfigPlanChecks : resource.ConfigPlanChecks {
4233
+ PreApply : []plancheck.PlanCheck {
4234
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionNoop ),
4235
+ },
4236
+ PostApplyPostRefresh : []plancheck.PlanCheck {
4237
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionNoop ),
4238
+ },
4239
+ },
4222
4240
})
4223
4241
}
4224
4242
@@ -4332,7 +4350,7 @@ type testAccMigrateTest struct {
4332
4350
PostCheck resource.TestCheckFunc
4333
4351
}
4334
4352
4335
- func (t testAccMigrateTest ) Steps () []resource.TestStep {
4353
+ func (t testAccMigrateTest ) Steps (resourceName string ) []resource.TestStep {
4336
4354
return []resource.TestStep {
4337
4355
{
4338
4356
ExternalProviders : map [string ]resource.ExternalProvider {
@@ -4343,6 +4361,11 @@ func (t testAccMigrateTest) Steps() []resource.TestStep {
4343
4361
},
4344
4362
Config : t .Config ,
4345
4363
Check : t .PreCheck ,
4364
+ ConfigPlanChecks : resource.ConfigPlanChecks {
4365
+ PreApply : []plancheck.PlanCheck {
4366
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionCreate ),
4367
+ },
4368
+ },
4346
4369
},
4347
4370
{
4348
4371
ExternalProviders : map [string ]resource.ExternalProvider {
@@ -4351,8 +4374,15 @@ func (t testAccMigrateTest) Steps() []resource.TestStep {
4351
4374
VersionConstraint : t .NextVersion ,
4352
4375
},
4353
4376
},
4354
- Config : t .Config ,
4355
- PlanOnly : true ,
4377
+ Config : t .Config ,
4378
+ ConfigPlanChecks : resource.ConfigPlanChecks {
4379
+ PreApply : []plancheck.PlanCheck {
4380
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionNoop ),
4381
+ },
4382
+ PostApplyPostRefresh : []plancheck.PlanCheck {
4383
+ plancheck .ExpectResourceAction (resourceName , plancheck .ResourceActionNoop ),
4384
+ },
4385
+ },
4356
4386
},
4357
4387
{
4358
4388
ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
0 commit comments