From 1f4dd7994b4dbddeae4ed3b418daf8ffe4321a7d Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 6 Mar 2020 17:13:15 -0500 Subject: [PATCH] Use 'acctest.RandomWithPrefix(tf-acc-test)' for resource names. --- aws/data_source_aws_instance_test.go | 38 ++++---- aws/data_source_aws_instances_test.go | 6 +- aws/resource_aws_instance_test.go | 126 +++++++++++++------------- 3 files changed, 85 insertions(+), 85 deletions(-) diff --git a/aws/data_source_aws_instance_test.go b/aws/data_source_aws_instance_test.go index 2046982aeeb..c04aa6274ef 100644 --- a/aws/data_source_aws_instance_test.go +++ b/aws/data_source_aws_instance_test.go @@ -12,7 +12,7 @@ import ( func TestAccAWSInstanceDataSource_basic(t *testing.T) { resourceName := "aws_instance.test" datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m1.small" resource.ParallelTest(t, resource.TestCase{ @@ -41,7 +41,7 @@ func TestAccAWSInstanceDataSource_basic(t *testing.T) { func TestAccAWSInstanceDataSource_tags(t *testing.T) { resourceName := "aws_instance.test" datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") rInt := acctest.RandInt() instanceType := "m1.small" @@ -69,7 +69,7 @@ func TestAccAWSInstanceDataSource_tags(t *testing.T) { func TestAccAWSInstanceDataSource_AzUserData(t *testing.T) { resourceName := "aws_instance.test" datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m1.small" resource.ParallelTest(t, resource.TestCase{ @@ -98,7 +98,7 @@ func TestAccAWSInstanceDataSource_AzUserData(t *testing.T) { func TestAccAWSInstanceDataSource_gp2IopsDevice(t *testing.T) { resourceName := "aws_instance.test" datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m3.medium" resource.ParallelTest(t, resource.TestCase{ @@ -128,7 +128,7 @@ func TestAccAWSInstanceDataSource_gp2IopsDevice(t *testing.T) { func TestAccAWSInstanceDataSource_blockDevices(t *testing.T) { resourceName := "aws_instance.test" datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m3.medium" resource.ParallelTest(t, resource.TestCase{ @@ -159,7 +159,7 @@ func TestAccAWSInstanceDataSource_blockDevices(t *testing.T) { // Test to verify that ebs_block_device kms_key_id does not elicit a panic func TestAccAWSInstanceDataSource_EbsBlockDevice_KmsKeyId(t *testing.T) { - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") // See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html#EBSEncryption_supported_instances. instanceType := "m3.medium" @@ -181,7 +181,7 @@ func TestAccAWSInstanceDataSource_EbsBlockDevice_KmsKeyId(t *testing.T) { // Test to verify that root_block_device kms_key_id does not elicit a panic func TestAccAWSInstanceDataSource_RootBlockDevice_KmsKeyId(t *testing.T) { - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") // See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html#EBSEncryption_supported_instances. instanceType := "m3.medium" @@ -204,7 +204,7 @@ func TestAccAWSInstanceDataSource_RootBlockDevice_KmsKeyId(t *testing.T) { func TestAccAWSInstanceDataSource_rootInstanceStore(t *testing.T) { resourceName := "aws_instance.test" datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m3.medium" resource.ParallelTest(t, resource.TestCase{ @@ -233,7 +233,7 @@ func TestAccAWSInstanceDataSource_rootInstanceStore(t *testing.T) { func TestAccAWSInstanceDataSource_privateIP(t *testing.T) { resourceName := "aws_instance.test" datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -255,7 +255,7 @@ func TestAccAWSInstanceDataSource_privateIP(t *testing.T) { func TestAccAWSInstanceDataSource_keyPair(t *testing.T) { resourceName := "aws_instance.test" datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t1.micro" resource.ParallelTest(t, resource.TestCase{ @@ -283,7 +283,7 @@ func TestAccAWSInstanceDataSource_keyPair(t *testing.T) { func TestAccAWSInstanceDataSource_VPC(t *testing.T) { resourceName := "aws_instance.test" datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m1.small" resource.ParallelTest(t, resource.TestCase{ @@ -307,7 +307,7 @@ func TestAccAWSInstanceDataSource_VPC(t *testing.T) { func TestAccAWSInstanceDataSource_PlacementGroup(t *testing.T) { resourceName := "aws_instance.test" datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "c3.large" resource.ParallelTest(t, resource.TestCase{ @@ -327,7 +327,7 @@ func TestAccAWSInstanceDataSource_PlacementGroup(t *testing.T) { func TestAccAWSInstanceDataSource_Ec2ClassicSecurityGroups(t *testing.T) { resourceName := "aws_instance.test" datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m1.small" resource.ParallelTest(t, resource.TestCase{ @@ -355,7 +355,7 @@ func TestAccAWSInstanceDataSource_Ec2ClassicSecurityGroups(t *testing.T) { func TestAccAWSInstanceDataSource_VPCSecurityGroups(t *testing.T) { resourceName := "aws_instance.test" datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t1.micro" resource.ParallelTest(t, resource.TestCase{ @@ -377,7 +377,7 @@ func TestAccAWSInstanceDataSource_VPCSecurityGroups(t *testing.T) { func TestAccAWSInstanceDataSource_getPasswordData_trueToFalse(t *testing.T) { datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.medium" resource.ParallelTest(t, resource.TestCase{ @@ -411,7 +411,7 @@ func TestAccAWSInstanceDataSource_getPasswordData_trueToFalse(t *testing.T) { func TestAccAWSInstanceDataSource_getPasswordData_falseToTrue(t *testing.T) { datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.medium" resource.ParallelTest(t, resource.TestCase{ @@ -445,7 +445,7 @@ func TestAccAWSInstanceDataSource_getPasswordData_falseToTrue(t *testing.T) { func TestAccAWSInstanceDataSource_GetUserData(t *testing.T) { datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -480,7 +480,7 @@ func TestAccAWSInstanceDataSource_GetUserData(t *testing.T) { func TestAccAWSInstanceDataSource_GetUserData_NoUserData(t *testing.T) { resourceName := "aws_instance.test" datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -518,7 +518,7 @@ func TestAccAWSInstanceDataSource_GetUserData_NoUserData(t *testing.T) { func TestAccAWSInstanceDataSource_creditSpecification(t *testing.T) { resourceName := "aws_instance.test" datasourceName := "data.aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ diff --git a/aws/data_source_aws_instances_test.go b/aws/data_source_aws_instances_test.go index c86e8d74396..016a9525801 100644 --- a/aws/data_source_aws_instances_test.go +++ b/aws/data_source_aws_instances_test.go @@ -10,7 +10,7 @@ import ( func TestAccAWSInstancesDataSource_basic(t *testing.T) { datasourceName := "data.aws_instances.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -39,7 +39,7 @@ func TestAccAWSInstancesDataSource_basic(t *testing.T) { func TestAccAWSInstancesDataSource_tags(t *testing.T) { datasourceName := "data.aws_instances.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -63,7 +63,7 @@ func TestAccAWSInstancesDataSource_tags(t *testing.T) { func TestAccAWSInstancesDataSource_instance_state_names(t *testing.T) { datasourceName := "data.aws_instances.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ diff --git a/aws/resource_aws_instance_test.go b/aws/resource_aws_instance_test.go index 072a0b5eda8..114197e4d60 100644 --- a/aws/resource_aws_instance_test.go +++ b/aws/resource_aws_instance_test.go @@ -148,7 +148,7 @@ func TestFetchRootDevice(t *testing.T) { func TestAccAWSInstance_inDefaultVpcBySgName(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -179,7 +179,7 @@ func TestAccAWSInstance_inDefaultVpcBySgName(t *testing.T) { func TestAccAWSInstance_inDefaultVpcBySgId(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -210,7 +210,7 @@ func TestAccAWSInstance_inDefaultVpcBySgId(t *testing.T) { func TestAccAWSInstance_inEc2Classic(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m3.medium" resource.ParallelTest(t, resource.TestCase{ @@ -283,7 +283,7 @@ func TestAccAWSInstance_basic(t *testing.T) { func TestAccAWSInstance_atLeastOneOtherEbsVolume(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m1.small" resource.ParallelTest(t, resource.TestCase{ @@ -330,7 +330,7 @@ func TestAccAWSInstance_EbsBlockDevice_KmsKeyArn(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" kmsKeyResourceName := "aws_kms_key.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") // See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html#EBSEncryption_supported_instances. instanceType := "m3.medium" @@ -361,7 +361,7 @@ func TestAccAWSInstance_RootBlockDevice_KmsKeyArn(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" kmsKeyResourceName := "aws_kms_key.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") // See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html#EBSEncryption_supported_instances. instanceType := "t3.nano" @@ -391,7 +391,7 @@ func TestAccAWSInstance_RootBlockDevice_KmsKeyArn(t *testing.T) { func TestAccAWSInstance_userDataBase64(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m1.small" resource.ParallelTest(t, resource.TestCase{ @@ -429,7 +429,7 @@ func TestAccAWSInstance_userDataBase64(t *testing.T) { func TestAccAWSInstance_GP2IopsDevice(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m3.medium" testCheck := func() resource.TestCheckFunc { @@ -491,7 +491,7 @@ func TestAccAWSInstance_GP2IopsDevice(t *testing.T) { func TestAccAWSInstance_GP2WithIopsValue(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m3.medium" resource.ParallelTest(t, resource.TestCase{ @@ -527,7 +527,7 @@ func TestAccAWSInstance_GP2WithIopsValue(t *testing.T) { func TestAccAWSInstance_blockDevices(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") // See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html#EBSEncryption_supported_instances. instanceType := "m3.medium" @@ -639,7 +639,7 @@ func TestAccAWSInstance_blockDevices(t *testing.T) { func TestAccAWSInstance_rootInstanceStore(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") // See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes. instanceType := "m3.medium" @@ -681,7 +681,7 @@ func TestAccAWSInstance_rootInstanceStore(t *testing.T) { func TestAccAWSInstance_noAMIEphemeralDevices(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "c3.large" testCheck := func() resource.TestCheckFunc { @@ -766,7 +766,7 @@ func TestAccAWSInstance_noAMIEphemeralDevices(t *testing.T) { func TestAccAWSInstance_sourceDestCheck(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m1.small" testCheck := func(enabled bool) resource.TestCheckFunc { @@ -821,7 +821,7 @@ func TestAccAWSInstance_sourceDestCheck(t *testing.T) { func TestAccAWSInstance_disableApiTermination(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m1.small" checkDisableApiTermination := func(expected bool) resource.TestCheckFunc { @@ -874,7 +874,7 @@ func TestAccAWSInstance_disableApiTermination(t *testing.T) { func TestAccAWSInstance_vpc(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m1.small" resource.ParallelTest(t, resource.TestCase{ @@ -908,7 +908,7 @@ func TestAccAWSInstance_vpc(t *testing.T) { func TestAccAWSInstance_placementGroup(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "c3.large" resource.ParallelTest(t, resource.TestCase{ @@ -941,7 +941,7 @@ func TestAccAWSInstance_placementGroup(t *testing.T) { func TestAccAWSInstance_ipv6_supportAddressCount(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -970,7 +970,7 @@ func TestAccAWSInstance_ipv6_supportAddressCount(t *testing.T) { } func TestAccAWSInstance_ipv6AddressCountAndSingleAddressCausesError(t *testing.T) { - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -989,7 +989,7 @@ func TestAccAWSInstance_ipv6AddressCountAndSingleAddressCausesError(t *testing.T func TestAccAWSInstance_ipv6_supportAddressCountWithIpv4(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -1020,7 +1020,7 @@ func TestAccAWSInstance_ipv6_supportAddressCountWithIpv4(t *testing.T) { func TestAccAWSInstance_NetworkInstanceSecurityGroups(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t1.micro" resource.ParallelTest(t, resource.TestCase{ @@ -1049,7 +1049,7 @@ func TestAccAWSInstance_NetworkInstanceSecurityGroups(t *testing.T) { func TestAccAWSInstance_NetworkInstanceRemovingAllSecurityGroups(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t1.micro" resource.ParallelTest(t, resource.TestCase{ @@ -1093,7 +1093,7 @@ func TestAccAWSInstance_NetworkInstanceRemovingAllSecurityGroups(t *testing.T) { func TestAccAWSInstance_NetworkInstanceVPCSecurityGroupIDs(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t1.micro" resource.ParallelTest(t, resource.TestCase{ @@ -1125,7 +1125,7 @@ func TestAccAWSInstance_NetworkInstanceVPCSecurityGroupIDs(t *testing.T) { func TestAccAWSInstance_tags(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m1.small" resource.ParallelTest(t, resource.TestCase{ @@ -1167,7 +1167,7 @@ func TestAccAWSInstance_tags(t *testing.T) { func TestAccAWSInstance_volumeTags(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") // See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html#EBSEncryption_supported_instances. instanceType := "m3.medium" @@ -1232,7 +1232,7 @@ func TestAccAWSInstance_volumeTags(t *testing.T) { func TestAccAWSInstance_volumeTagsComputed(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.medium" resource.ParallelTest(t, resource.TestCase{ @@ -1265,8 +1265,8 @@ func TestAccAWSInstance_volumeTagsComputed(t *testing.T) { func TestAccAWSInstance_instanceProfileChange(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) - rName2 := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") + rName2 := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m1.small" testCheckInstanceProfile := func() resource.TestCheckFunc { @@ -1328,7 +1328,7 @@ func TestAccAWSInstance_instanceProfileChange(t *testing.T) { func TestAccAWSInstance_withIamInstanceProfile(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m1.small" testCheckInstanceProfile := func() resource.TestCheckFunc { @@ -1371,7 +1371,7 @@ func TestAccAWSInstance_withIamInstanceProfile(t *testing.T) { func TestAccAWSInstance_privateIP(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" testCheckPrivateIP := func() resource.TestCheckFunc { @@ -1409,7 +1409,7 @@ func TestAccAWSInstance_privateIP(t *testing.T) { func TestAccAWSInstance_associatePublicIPAndPrivateIP(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" testCheckPrivateIP := func() resource.TestCheckFunc { @@ -1450,7 +1450,7 @@ func TestAccAWSInstance_associatePublicIPAndPrivateIP(t *testing.T) { func TestAccAWSInstance_keyPairCheck(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t1.micro" testCheckKeyPair := func(keyName string) resource.TestCheckFunc { @@ -1492,7 +1492,7 @@ func TestAccAWSInstance_keyPairCheck(t *testing.T) { func TestAccAWSInstance_rootBlockDeviceMismatch(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t1.micro" resource.ParallelTest(t, resource.TestCase{ @@ -1534,7 +1534,7 @@ func TestAccAWSInstance_rootBlockDeviceMismatch(t *testing.T) { func TestAccAWSInstance_forceNewAndTagsDrift(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.nano" resource.ParallelTest(t, resource.TestCase{ @@ -1570,7 +1570,7 @@ func TestAccAWSInstance_changeInstanceType(t *testing.T) { var before ec2.Instance var after ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceTypeBefore := "m3.medium" instanceTypeAfter := "m3.large" @@ -1613,7 +1613,7 @@ func TestAccAWSInstance_primaryNetworkInterface(t *testing.T) { var eni ec2.NetworkInterface resourceName := "aws_instance.test" eniResourceName := "aws_network_interface.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -1644,7 +1644,7 @@ func TestAccAWSInstance_primaryNetworkInterfaceSourceDestCheck(t *testing.T) { var eni ec2.NetworkInterface resourceName := "aws_instance.test" eniResourceName := "aws_network_interface.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -1678,7 +1678,7 @@ func TestAccAWSInstance_addSecondaryInterface(t *testing.T) { resourceName := "aws_instance.test" eniPrimaryResourceName := "aws_network_interface.primary" eniSecondaryResourceName := "aws_network_interface.secondary" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -1717,7 +1717,7 @@ func TestAccAWSInstance_addSecurityGroupNetworkInterface(t *testing.T) { var before ec2.Instance var after ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -1752,7 +1752,7 @@ func TestAccAWSInstance_addSecurityGroupNetworkInterface(t *testing.T) { func TestAccAWSInstance_associatePublic_defaultPrivate(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -1781,7 +1781,7 @@ func TestAccAWSInstance_associatePublic_defaultPrivate(t *testing.T) { func TestAccAWSInstance_associatePublic_defaultPublic(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -1810,7 +1810,7 @@ func TestAccAWSInstance_associatePublic_defaultPublic(t *testing.T) { func TestAccAWSInstance_associatePublic_explicitPublic(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -1839,7 +1839,7 @@ func TestAccAWSInstance_associatePublic_explicitPublic(t *testing.T) { func TestAccAWSInstance_associatePublic_explicitPrivate(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -1868,7 +1868,7 @@ func TestAccAWSInstance_associatePublic_explicitPrivate(t *testing.T) { func TestAccAWSInstance_associatePublic_overridePublic(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -1897,7 +1897,7 @@ func TestAccAWSInstance_associatePublic_overridePublic(t *testing.T) { func TestAccAWSInstance_associatePublic_overridePrivate(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -1925,7 +1925,7 @@ func TestAccAWSInstance_associatePublic_overridePrivate(t *testing.T) { func TestAccAWSInstance_getPasswordData_falseToTrue(t *testing.T) { var before, after ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.medium" resource.ParallelTest(t, resource.TestCase{ @@ -1969,7 +1969,7 @@ func TestAccAWSInstance_getPasswordData_falseToTrue(t *testing.T) { func TestAccAWSInstance_getPasswordData_trueToFalse(t *testing.T) { var before, after ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.medium" resource.ParallelTest(t, resource.TestCase{ @@ -2014,7 +2014,7 @@ func TestAccAWSInstance_getPasswordData_trueToFalse(t *testing.T) { func TestAccAWSInstance_CreditSpecification_Empty_NonBurstable(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m5.large" resource.ParallelTest(t, resource.TestCase{ @@ -2042,7 +2042,7 @@ func TestAccAWSInstance_CreditSpecification_Empty_NonBurstable(t *testing.T) { func TestAccAWSInstance_CreditSpecification_UnspecifiedToEmpty_NonBurstable(t *testing.T) { var instance ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m5.large" resource.ParallelTest(t, resource.TestCase{ @@ -2074,7 +2074,7 @@ func TestAccAWSInstance_CreditSpecification_UnspecifiedToEmpty_NonBurstable(t *t func TestAccAWSInstance_creditSpecification_unspecifiedDefaultsToStandard(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -2102,7 +2102,7 @@ func TestAccAWSInstance_creditSpecification_unspecifiedDefaultsToStandard(t *tes func TestAccAWSInstance_creditSpecification_standardCpuCredits(t *testing.T) { var first, second ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -2138,7 +2138,7 @@ func TestAccAWSInstance_creditSpecification_standardCpuCredits(t *testing.T) { func TestAccAWSInstance_creditSpecification_unlimitedCpuCredits(t *testing.T) { var first, second ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -2174,7 +2174,7 @@ func TestAccAWSInstance_creditSpecification_unlimitedCpuCredits(t *testing.T) { func TestAccAWSInstance_creditSpecification_unknownCpuCredits_t2(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -2202,7 +2202,7 @@ func TestAccAWSInstance_creditSpecification_unknownCpuCredits_t2(t *testing.T) { func TestAccAWSInstance_creditSpecification_unknownCpuCredits_t3(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t3.micro" resource.ParallelTest(t, resource.TestCase{ @@ -2230,7 +2230,7 @@ func TestAccAWSInstance_creditSpecification_unknownCpuCredits_t3(t *testing.T) { func TestAccAWSInstance_creditSpecification_updateCpuCredits(t *testing.T) { var first, second, third ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -2274,7 +2274,7 @@ func TestAccAWSInstance_creditSpecification_updateCpuCredits(t *testing.T) { func TestAccAWSInstance_creditSpecification_isNotAppliedToNonBurstable(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "m1.small" resource.ParallelTest(t, resource.TestCase{ @@ -2301,7 +2301,7 @@ func TestAccAWSInstance_creditSpecification_isNotAppliedToNonBurstable(t *testin func TestAccAWSInstance_creditSpecificationT3_unspecifiedDefaultsToUnlimited(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t3.micro" resource.ParallelTest(t, resource.TestCase{ @@ -2329,7 +2329,7 @@ func TestAccAWSInstance_creditSpecificationT3_unspecifiedDefaultsToUnlimited(t * func TestAccAWSInstance_creditSpecificationT3_standardCpuCredits(t *testing.T) { var first, second ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t3.micro" resource.ParallelTest(t, resource.TestCase{ @@ -2365,7 +2365,7 @@ func TestAccAWSInstance_creditSpecificationT3_standardCpuCredits(t *testing.T) { func TestAccAWSInstance_creditSpecificationT3_unlimitedCpuCredits(t *testing.T) { var first, second ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t3.micro" resource.ParallelTest(t, resource.TestCase{ @@ -2401,7 +2401,7 @@ func TestAccAWSInstance_creditSpecificationT3_unlimitedCpuCredits(t *testing.T) func TestAccAWSInstance_creditSpecificationT3_updateCpuCredits(t *testing.T) { var first, second, third ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t3.micro" resource.ParallelTest(t, resource.TestCase{ @@ -2445,7 +2445,7 @@ func TestAccAWSInstance_creditSpecificationT3_updateCpuCredits(t *testing.T) { func TestAccAWSInstance_creditSpecification_standardCpuCredits_t2Tot3Taint(t *testing.T) { var before, after ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceTypeT2 := "t2.micro" instanceTypeT3 := "t3.micro" @@ -2487,7 +2487,7 @@ func TestAccAWSInstance_creditSpecification_standardCpuCredits_t2Tot3Taint(t *te func TestAccAWSInstance_creditSpecification_unlimitedCpuCredits_t2Tot3Taint(t *testing.T) { var before, after ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceTypeT2 := "t2.micro" instanceTypeT3 := "t3.micro" @@ -2556,7 +2556,7 @@ func TestAccAWSInstance_disappears(t *testing.T) { func TestAccAWSInstance_UserData_EmptyStringToUnspecified(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{ @@ -2589,7 +2589,7 @@ func TestAccAWSInstance_UserData_EmptyStringToUnspecified(t *testing.T) { func TestAccAWSInstance_UserData_UnspecifiedToEmptyString(t *testing.T) { var v ec2.Instance resourceName := "aws_instance.test" - rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum)) + rName := acctest.RandomWithPrefix("tf-acc-test") instanceType := "t2.micro" resource.ParallelTest(t, resource.TestCase{