Skip to content

Commit 519c297

Browse files
committed
Update for rName
1 parent a8a1636 commit 519c297

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

internal/service/ec2/stop_instance_action_test.go

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func TestAccEC2StopInstanceAction_basic(t *testing.T) {
2121
ctx := acctest.Context(t)
2222
var v awstypes.Instance
2323
resourceName := "aws_instance.test"
24+
rName := acctest.RandomWithPrefix(t, acctest.ResourcePrefix)
2425

2526
resource.ParallelTest(t, resource.TestCase{
2627
PreCheck: func() {
@@ -31,14 +32,14 @@ func TestAccEC2StopInstanceAction_basic(t *testing.T) {
3132
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
3233
Steps: []resource.TestStep{
3334
{
34-
Config: testAccStopInstanceActionConfig_basic(),
35+
Config: testAccStopInstanceActionConfig_basic(rName),
3536
Check: resource.ComposeTestCheckFunc(
3637
testAccCheckInstanceExists(ctx, resourceName, &v),
3738
testAccCheckInstanceState(ctx, resourceName, awstypes.InstanceStateNameRunning),
3839
),
3940
},
4041
{
41-
Config: testAccStopInstanceActionConfig_withAction(),
42+
Config: testAccStopInstanceActionConfig_withAction(rName),
4243
Check: resource.ComposeTestCheckFunc(
4344
testAccCheckInstanceExists(ctx, resourceName, &v),
4445
testAccCheckInstanceState(ctx, resourceName, awstypes.InstanceStateNameStopped),
@@ -52,6 +53,7 @@ func TestAccEC2StopInstanceAction_force(t *testing.T) {
5253
ctx := acctest.Context(t)
5354
var v awstypes.Instance
5455
resourceName := "aws_instance.test"
56+
rName := acctest.RandomWithPrefix(t, acctest.ResourcePrefix)
5557

5658
resource.ParallelTest(t, resource.TestCase{
5759
PreCheck: func() {
@@ -62,14 +64,14 @@ func TestAccEC2StopInstanceAction_force(t *testing.T) {
6264
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
6365
Steps: []resource.TestStep{
6466
{
65-
Config: testAccStopInstanceActionConfig_basic(),
67+
Config: testAccStopInstanceActionConfig_basic(rName),
6668
Check: resource.ComposeTestCheckFunc(
6769
testAccCheckInstanceExists(ctx, resourceName, &v),
6870
testAccCheckInstanceState(ctx, resourceName, awstypes.InstanceStateNameRunning),
6971
),
7072
},
7173
{
72-
Config: testAccStopInstanceActionConfig_withForce(),
74+
Config: testAccStopInstanceActionConfig_withForce(rName),
7375
Check: resource.ComposeTestCheckFunc(
7476
testAccCheckInstanceExists(ctx, resourceName, &v),
7577
testAccCheckInstanceState(ctx, resourceName, awstypes.InstanceStateNameStopped),
@@ -83,6 +85,7 @@ func TestAccEC2StopInstanceAction_customTimeout(t *testing.T) {
8385
ctx := acctest.Context(t)
8486
var v awstypes.Instance
8587
resourceName := "aws_instance.test"
88+
rName := acctest.RandomWithPrefix(t, acctest.ResourcePrefix)
8689

8790
resource.ParallelTest(t, resource.TestCase{
8891
PreCheck: func() {
@@ -93,14 +96,14 @@ func TestAccEC2StopInstanceAction_customTimeout(t *testing.T) {
9396
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
9497
Steps: []resource.TestStep{
9598
{
96-
Config: testAccStopInstanceActionConfig_basic(),
99+
Config: testAccStopInstanceActionConfig_basic(rName),
97100
Check: resource.ComposeTestCheckFunc(
98101
testAccCheckInstanceExists(ctx, resourceName, &v),
99102
testAccCheckInstanceState(ctx, resourceName, awstypes.InstanceStateNameRunning),
100103
),
101104
},
102105
{
103-
Config: testAccStopInstanceActionConfig_withTimeout(),
106+
Config: testAccStopInstanceActionConfig_withTimeout(rName),
104107
Check: resource.ComposeTestCheckFunc(
105108
testAccCheckInstanceExists(ctx, resourceName, &v),
106109
testAccCheckInstanceState(ctx, resourceName, awstypes.InstanceStateNameStopped),
@@ -137,26 +140,26 @@ func testAccCheckInstanceState(ctx context.Context, n string, expectedState awst
137140
}
138141
}
139142

140-
func testAccStopInstanceActionConfig_basic() string {
143+
func testAccStopInstanceActionConfig_basic(rName string) string {
141144
return acctest.ConfigCompose(
142145
acctest.ConfigLatestAmazonLinux2HVMEBSX8664AMI(),
143146
acctest.ConfigAvailableAZsNoOptIn(),
144147
acctest.AvailableEC2InstanceTypeForAvailabilityZone("data.aws_availability_zones.available.names[0]", "t3.micro", "t2.micro"),
145-
`
148+
fmt.Sprintf(`
146149
resource "aws_instance" "test" {
147150
ami = data.aws_ami.amzn2-ami-minimal-hvm-ebs-x86_64.id
148151
instance_type = data.aws_ec2_instance_type_offering.available.instance_type
149152
150153
tags = {
151-
Name = "terraform-testacc-stop-instance-action"
154+
Name = %[1]q
152155
}
153156
}
154-
`)
157+
`, rName))
155158
}
156159

157-
func testAccStopInstanceActionConfig_withAction() string {
160+
func testAccStopInstanceActionConfig_withAction(rName string) string {
158161
return acctest.ConfigCompose(
159-
testAccStopInstanceActionConfig_basic(),
162+
testAccStopInstanceActionConfig_basic(rName),
160163
`
161164
action "aws_ec2_stop_instance" "test" {
162165
config {
@@ -166,9 +169,9 @@ action "aws_ec2_stop_instance" "test" {
166169
`)
167170
}
168171

169-
func testAccStopInstanceActionConfig_withForce() string {
172+
func testAccStopInstanceActionConfig_withForce(rName string) string {
170173
return acctest.ConfigCompose(
171-
testAccStopInstanceActionConfig_basic(),
174+
testAccStopInstanceActionConfig_basic(rName),
172175
`
173176
action "aws_ec2_stop_instance" "test" {
174177
config {
@@ -179,9 +182,9 @@ action "aws_ec2_stop_instance" "test" {
179182
`)
180183
}
181184

182-
func testAccStopInstanceActionConfig_withTimeout() string {
185+
func testAccStopInstanceActionConfig_withTimeout(rName string) string {
183186
return acctest.ConfigCompose(
184-
testAccStopInstanceActionConfig_basic(),
187+
testAccStopInstanceActionConfig_basic(rName),
185188
`
186189
action "aws_ec2_stop_instance" "test" {
187190
config {

0 commit comments

Comments
 (0)