Skip to content

Commit a4315ae

Browse files
authored
tests/provider: Migrate additional tests to newer ProviderFactories setup and PreCheck functions (#15877)
Reference: #8316 Reference: #15737 Reference: #15791 This creates the remaining special `ProviderFactories` functions (as they need to exist currently), updates the Contributing Guide documentation, and migrates a portion of the tests over to them. Further changesets will continue these efforts by: * Migrating the rest of the `awsalternate` provider test configurations to `testAccProviderFactoriesAlternate()` * Migrating the rest of the `testAccMultipleRegionsPreCheck()` and `testAccAlternateRegionPreCheck()` usage to `testAccMultipleRegionPreCheck()` (bundling with the above as its fairly common together) * Flipping `testAccProviderFactories` to a variable with only the `aws` provider and replacing `testAccProviderFactoriesEc2Classic` and `testAccProviderFactoriesCur()` * Continuing efforts to remove environment variable handling in test functions Output from acceptance testing in AWS Commercial: ``` --- PASS: TestAccAwsBackupPlan_Rule_CopyAction_CrossRegion (20.85s) --- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn (157.90s) --- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn_ConflictsWithCloudFrontDefaultCertificate (157.61s) --- FAIL: TestAccAWSDBInstance_DbSubnetGroupName_RamShared (18.95s) resource_aws_db_instance_test.go:352: Step 1/1 error: Error running apply: 2020/10/27 23:13:26 [DEBUG] Using modified User-Agent: Terraform/0.12.29 HashiCorp-terraform-exec/0.10.0 Error: Error associating principal with RAM resource share: UnknownResourceException: Organization o-upyv668dz5 could not be found. Error: error associating RAM Resource Share: InvalidParameterException: The resource you are attempting to share can only be shared within your AWS Organization. This error may also occur if you have not enabled sharing with your AWS organization, or that onboarding process is still in progress. Error: error associating RAM Resource Share: InvalidParameterException: The resource you are attempting to share can only be shared within your AWS Organization. This error may also occur if you have not enabled sharing with your AWS organization, or that onboarding process is still in progress. --- FAIL: TestAccAWSDBInstance_ReplicateSourceDb_DbSubnetGroupName_RamShared (604.80s) resource_aws_db_instance_test.go:808: Step 1/1 error: Error running apply: 2020/10/27 21:59:55 [DEBUG] Using modified User-Agent: Terraform/0.12.29 HashiCorp-terraform-exec/0.10.0 Error: Error associating principal with RAM resource share: UnknownResourceException: Organization o-upyv668dz5 could not be found. Error: error associating RAM Resource Share: InvalidParameterException: The resource you are attempting to share can only be shared within your AWS Organization. This error may also occur if you have not enabled sharing with your AWS organization, or that onboarding process is still in progress. Error: error associating RAM Resource Share: InvalidParameterException: The resource you are attempting to share can only be shared within your AWS Organization. This error may also occur if you have not enabled sharing with your AWS organization, or that onboarding process is still in progress. --- FAIL: TestAccAWSDBInstance_SnapshotIdentifier_DbSubnetGroupName_RamShared (615.89s) resource_aws_db_instance_test.go:1437: Step 1/1 error: Error running apply: 2020/10/27 23:13:26 [DEBUG] Using modified User-Agent: Terraform/0.12.29 HashiCorp-terraform-exec/0.10.0 Error: Error associating principal with RAM resource share: UnknownResourceException: Organization o-upyv668dz5 could not be found. Error: error associating RAM Resource Share: InvalidParameterException: The resource you are attempting to share can only be shared within your AWS Organization. This error may also occur if you have not enabled sharing with your AWS organization, or that onboarding process is still in progress. Error: error associating RAM Resource Share: InvalidParameterException: The resource you are attempting to share can only be shared within your AWS Organization. This error may also occur if you have not enabled sharing with your AWS organization, or that onboarding process is still in progress. --- PASS: TestAccAWSDBInstance_ReplicateSourceDb_DbSubnetGroupName (2252.27s) --- PASS: TestAccAWSDBInstance_ReplicateSourceDb_DbSubnetGroupName_VpcSecurityGroupIds (1908.33s) --- PASS: TestAccAWSDynamoDbTable_Replica_Multiple (766.22s) --- PASS: TestAccAWSDynamoDbTable_Replica_Single (412.01s) --- PASS: TestAccAWSEc2TransitGatewayPeeringAttachment_basic (376.21s) --- PASS: TestAccAWSEc2TransitGatewayPeeringAttachment_differentAccount (360.55s) --- PASS: TestAccAWSEc2TransitGatewayPeeringAttachment_disappears (363.16s) --- PASS: TestAccAWSEc2TransitGatewayPeeringAttachment_Tags_sameAccount (365.29s) --- PASS: TestAccAWSEc2TransitGatewayPeeringAttachmentAccepter_basic_differentAccount (780.52s) --- PASS: TestAccAWSEc2TransitGatewayPeeringAttachmentAccepter_basic_sameAccount (773.52s) --- PASS: TestAccAWSEc2TransitGatewayPeeringAttachmentAccepter_Tags_sameAccount (815.32s) --- PASS: TestAccAWSEc2TransitGatewayPeeringAttachmentDataSource_Filter_differentAccount (389.30s) --- PASS: TestAccAWSEc2TransitGatewayPeeringAttachmentDataSource_Filter_sameAccount (397.06s) --- PASS: TestAccAWSEc2TransitGatewayPeeringAttachmentDataSource_ID_differentAccount (333.33s) --- PASS: TestAccAWSEc2TransitGatewayPeeringAttachmentDataSource_ID_sameAccount (333.84s) --- PASS: TestAccAWSEc2TransitGatewayPeeringAttachmentDataSource_Tags (332.99s) --- PASS: TestAccAWSProvider_AssumeRole_Empty (16.67s) --- PASS: TestAccAWSProvider_Endpoints (14.28s) --- PASS: TestAccAWSProvider_IgnoreTags_EmptyConfigurationBlock (14.21s) --- PASS: TestAccAWSProvider_IgnoreTags_KeyPrefixes_Multiple (14.15s) --- PASS: TestAccAWSProvider_IgnoreTags_KeyPrefixes_None (14.28s) --- PASS: TestAccAWSProvider_IgnoreTags_KeyPrefixes_One (14.05s) --- PASS: TestAccAWSProvider_IgnoreTags_Keys_Multiple (14.11s) --- PASS: TestAccAWSProvider_IgnoreTags_Keys_None (14.19s) --- PASS: TestAccAWSProvider_IgnoreTags_Keys_One (14.31s) --- PASS: TestAccAWSProvider_Region_AwsChina (11.20s) --- PASS: TestAccAWSProvider_Region_AwsCommercial (11.54s) --- PASS: TestAccAWSProvider_Region_AwsGovCloudUs (11.22s) ``` Output from acceptance testing in AWS GovCloud (US): ``` --- PASS: TestAccAwsBackupPlan_Rule_CopyAction_CrossRegion (24.77s) --- SKIP: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn (1.52s) --- SKIP: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn_ConflictsWithCloudFrontDefaultCertificate (1.55s) ```
1 parent ddd04f1 commit a4315ae

10 files changed

+127
-95
lines changed

aws/cloudfront_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package aws
2+
3+
import "github.com/aws/aws-sdk-go/aws/endpoints"
4+
5+
// testAccCloudfrontRegionProviderConfig is the Terraform provider configuration for CloudFront region testing
6+
//
7+
// Testing CloudFront assumes no other provider configurations
8+
// are necessary and overwrites the "aws" provider configuration.
9+
func testAccCloudfrontRegionProviderConfig() string {
10+
switch testAccGetPartition() {
11+
case endpoints.AwsPartitionID:
12+
return testAccRegionalProviderConfig(endpoints.UsEast1RegionID)
13+
case endpoints.AwsCnPartitionID:
14+
return testAccRegionalProviderConfig(endpoints.CnNorthwest1RegionID)
15+
default:
16+
return testAccRegionalProviderConfig(testAccGetRegion())
17+
}
18+
}

aws/data_source_aws_ec2_transit_gateway_peering_attachment_test.go

+12-15
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ func TestAccAWSEc2TransitGatewayPeeringAttachmentDataSource_Filter_sameAccount(t
1717
PreCheck: func() {
1818
testAccPreCheck(t)
1919
testAccPreCheckAWSEc2TransitGateway(t)
20-
testAccMultipleRegionsPreCheck(t)
21-
testAccAlternateRegionPreCheck(t)
20+
testAccMultipleRegionPreCheck(t, 2)
2221
},
23-
ProviderFactories: testAccProviderFactories(&providers),
22+
ProviderFactories: testAccProviderFactoriesAlternate(&providers),
2423
CheckDestroy: testAccCheckAWSEc2TransitGatewayDestroy,
2524
Steps: []resource.TestStep{
2625
{
@@ -46,10 +45,10 @@ func TestAccAWSEc2TransitGatewayPeeringAttachmentDataSource_Filter_differentAcco
4645
PreCheck: func() {
4746
testAccPreCheck(t)
4847
testAccPreCheckAWSEc2TransitGateway(t)
49-
testAccMultipleRegionsPreCheck(t)
50-
testAccAlternateRegionPreCheck(t)
48+
testAccMultipleRegionPreCheck(t, 2)
49+
testAccAlternateAccountPreCheck(t)
5150
},
52-
ProviderFactories: testAccProviderFactories(&providers),
51+
ProviderFactories: testAccProviderFactoriesAlternate(&providers),
5352
CheckDestroy: testAccCheckAWSEc2TransitGatewayDestroy,
5453
Steps: []resource.TestStep{
5554
{
@@ -73,10 +72,9 @@ func TestAccAWSEc2TransitGatewayPeeringAttachmentDataSource_ID_sameAccount(t *te
7372
PreCheck: func() {
7473
testAccPreCheck(t)
7574
testAccPreCheckAWSEc2TransitGateway(t)
76-
testAccMultipleRegionsPreCheck(t)
77-
testAccAlternateRegionPreCheck(t)
75+
testAccMultipleRegionPreCheck(t, 2)
7876
},
79-
ProviderFactories: testAccProviderFactories(&providers),
77+
ProviderFactories: testAccProviderFactoriesAlternate(&providers),
8078
CheckDestroy: testAccCheckAWSEc2TransitGatewayDestroy,
8179
Steps: []resource.TestStep{
8280
{
@@ -102,10 +100,10 @@ func TestAccAWSEc2TransitGatewayPeeringAttachmentDataSource_ID_differentAccount(
102100
PreCheck: func() {
103101
testAccPreCheck(t)
104102
testAccPreCheckAWSEc2TransitGateway(t)
105-
testAccMultipleRegionsPreCheck(t)
106-
testAccAlternateRegionPreCheck(t)
103+
testAccMultipleRegionPreCheck(t, 2)
104+
testAccAlternateAccountPreCheck(t)
107105
},
108-
ProviderFactories: testAccProviderFactories(&providers),
106+
ProviderFactories: testAccProviderFactoriesAlternate(&providers),
109107
CheckDestroy: testAccCheckAWSEc2TransitGatewayDestroy,
110108
Steps: []resource.TestStep{
111109
{
@@ -129,10 +127,9 @@ func TestAccAWSEc2TransitGatewayPeeringAttachmentDataSource_Tags(t *testing.T) {
129127
PreCheck: func() {
130128
testAccPreCheck(t)
131129
testAccPreCheckAWSEc2TransitGateway(t)
132-
testAccMultipleRegionsPreCheck(t)
133-
testAccAlternateRegionPreCheck(t)
130+
testAccMultipleRegionPreCheck(t, 2)
134131
},
135-
ProviderFactories: testAccProviderFactories(&providers),
132+
ProviderFactories: testAccProviderFactoriesAlternate(&providers),
136133
CheckDestroy: testAccCheckAWSEc2TransitGatewayDestroy,
137134
Steps: []resource.TestStep{
138135
{

aws/provider_test.go

+62-34
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ const (
4242

4343
// Provider name for third configuration testing
4444
ProviderNameAwsThird = "awsthird"
45-
46-
// Provider name for hardcoded us-east-1 configuration testing
47-
//
48-
// Deprecated: This will be replaced with service specific providers
49-
ProviderNameAwsUsEast1 = "awsus-east-1"
5045
)
5146

5247
const rfc3339RegexPattern = `^[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?([Zz]|([+-]([01][0-9]|2[0-3]):[0-5][0-9]))$`
@@ -99,11 +94,6 @@ func init() {
9994
return testAccProviderFactoriesInit(providers, []string{
10095
ProviderNameAws,
10196
ProviderNameAwsAlternate,
102-
ProviderNameAwsAlternateAccountAlternateRegion,
103-
ProviderNameAwsAlternateAccountSameRegion,
104-
ProviderNameAwsSameAccountAlternateRegion,
105-
ProviderNameAwsThird,
106-
ProviderNameAwsUsEast1,
10797
})
10898
}
10999
testAccProviderFunc = func() *schema.Provider { return testAccProvider }
@@ -128,6 +118,56 @@ func testAccProviderFactoriesInit(providers *[]*schema.Provider, providerNames [
128118
return factories
129119
}
130120

121+
// testAccProviderFactoriesInternal creates ProviderFactories for provider configuration testing
122+
//
123+
// This should only be used for TestAccAWSProvider_ tests which need to
124+
// reference the provider instance itself. Other testing should use
125+
// testAccProviderFactories or other related functions.
126+
func testAccProviderFactoriesInternal(providers *[]*schema.Provider) map[string]func() (*schema.Provider, error) {
127+
return testAccProviderFactoriesInit(providers, []string{ProviderNameAws})
128+
}
129+
130+
// testAccProviderFactoriesAlternate creates ProviderFactories for cross-account and cross-region configurations
131+
//
132+
// For cross-region testing: Typically paired with testAccMultipleRegionPreCheck and testAccAlternateRegionProviderConfig.
133+
//
134+
// For cross-account testing: Typically paired with testAccAlternateAccountPreCheck and testAccAlternateAccountProviderConfig.
135+
func testAccProviderFactoriesAlternate(providers *[]*schema.Provider) map[string]func() (*schema.Provider, error) {
136+
return testAccProviderFactoriesInit(providers, []string{
137+
ProviderNameAws,
138+
ProviderNameAwsAlternate,
139+
})
140+
}
141+
142+
// testAccProviderFactoriesAlternateAccountAndAlternateRegion creates ProviderFactories for cross-account and cross-region configurations
143+
//
144+
// Usage typically paired with testAccMultipleRegionPreCheck, testAccAlternateAccountPreCheck,
145+
// and testAccAlternateAccountAndAlternateRegionProviderConfig.
146+
func testAccProviderFactoriesAlternateAccountAndAlternateRegion(providers *[]*schema.Provider) map[string]func() (*schema.Provider, error) {
147+
return testAccProviderFactoriesInit(providers, []string{
148+
ProviderNameAws,
149+
ProviderNameAwsAlternateAccountAlternateRegion,
150+
ProviderNameAwsAlternateAccountSameRegion,
151+
ProviderNameAwsSameAccountAlternateRegion,
152+
})
153+
}
154+
155+
// testAccProviderFactoriesMultipleRegion creates ProviderFactories for the number of region configurations
156+
//
157+
// Usage typically paired with testAccMultipleRegionPreCheck and testAccMultipleRegionProviderConfig.
158+
func testAccProviderFactoriesMultipleRegion(providers *[]*schema.Provider, regions int) map[string]func() (*schema.Provider, error) {
159+
providerNames := []string{
160+
ProviderNameAws,
161+
ProviderNameAwsAlternate,
162+
}
163+
164+
if regions >= 3 {
165+
providerNames = append(providerNames, ProviderNameAwsThird)
166+
}
167+
168+
return testAccProviderFactoriesInit(providers, providerNames)
169+
}
170+
131171
func TestProvider(t *testing.T) {
132172
if err := Provider().InternalValidate(); err != nil {
133173
t.Fatalf("err: %s", err)
@@ -823,18 +863,6 @@ provider "aws" {
823863
`, region)
824864
}
825865

826-
// Provider configuration hardcoded for us-east-1.
827-
// This should only be necessary for testing ACM Certificates with CloudFront
828-
// related infrastucture such as API Gateway Domain Names for EDGE endpoints,
829-
// CloudFront Distribution Viewer Certificates, and Cognito User Pool Domains.
830-
// Other valid usage is for services only available in us-east-1 such as the
831-
// Cost and Usage Reporting and Pricing services.
832-
//
833-
// Deprecated: This will be replaced with service specific provider configurations.
834-
func testAccUsEast1RegionProviderConfig() string {
835-
return testAccNamedRegionalProviderConfig(ProviderNameAwsUsEast1, endpoints.UsEast1RegionID)
836-
}
837-
838866
func testAccAwsRegionProviderFunc(region string, providers *[]*schema.Provider) func() *schema.Provider {
839867
return func() *schema.Provider {
840868
if region == "" {
@@ -998,7 +1026,7 @@ func TestAccAWSProvider_Endpoints(t *testing.T) {
9981026

9991027
resource.ParallelTest(t, resource.TestCase{
10001028
PreCheck: func() { testAccPreCheck(t) },
1001-
ProviderFactories: testAccProviderFactories(&providers),
1029+
ProviderFactories: testAccProviderFactoriesInternal(&providers),
10021030
CheckDestroy: nil,
10031031
Steps: []resource.TestStep{
10041032
{
@@ -1016,7 +1044,7 @@ func TestAccAWSProvider_IgnoreTags_EmptyConfigurationBlock(t *testing.T) {
10161044

10171045
resource.ParallelTest(t, resource.TestCase{
10181046
PreCheck: func() { testAccPreCheck(t) },
1019-
ProviderFactories: testAccProviderFactories(&providers),
1047+
ProviderFactories: testAccProviderFactoriesInternal(&providers),
10201048
CheckDestroy: nil,
10211049
Steps: []resource.TestStep{
10221050
{
@@ -1035,7 +1063,7 @@ func TestAccAWSProvider_IgnoreTags_KeyPrefixes_None(t *testing.T) {
10351063

10361064
resource.ParallelTest(t, resource.TestCase{
10371065
PreCheck: func() { testAccPreCheck(t) },
1038-
ProviderFactories: testAccProviderFactories(&providers),
1066+
ProviderFactories: testAccProviderFactoriesInternal(&providers),
10391067
CheckDestroy: nil,
10401068
Steps: []resource.TestStep{
10411069
{
@@ -1053,7 +1081,7 @@ func TestAccAWSProvider_IgnoreTags_KeyPrefixes_One(t *testing.T) {
10531081

10541082
resource.ParallelTest(t, resource.TestCase{
10551083
PreCheck: func() { testAccPreCheck(t) },
1056-
ProviderFactories: testAccProviderFactories(&providers),
1084+
ProviderFactories: testAccProviderFactoriesInternal(&providers),
10571085
CheckDestroy: nil,
10581086
Steps: []resource.TestStep{
10591087
{
@@ -1071,7 +1099,7 @@ func TestAccAWSProvider_IgnoreTags_KeyPrefixes_Multiple(t *testing.T) {
10711099

10721100
resource.ParallelTest(t, resource.TestCase{
10731101
PreCheck: func() { testAccPreCheck(t) },
1074-
ProviderFactories: testAccProviderFactories(&providers),
1102+
ProviderFactories: testAccProviderFactoriesInternal(&providers),
10751103
CheckDestroy: nil,
10761104
Steps: []resource.TestStep{
10771105
{
@@ -1089,7 +1117,7 @@ func TestAccAWSProvider_IgnoreTags_Keys_None(t *testing.T) {
10891117

10901118
resource.ParallelTest(t, resource.TestCase{
10911119
PreCheck: func() { testAccPreCheck(t) },
1092-
ProviderFactories: testAccProviderFactories(&providers),
1120+
ProviderFactories: testAccProviderFactoriesInternal(&providers),
10931121
CheckDestroy: nil,
10941122
Steps: []resource.TestStep{
10951123
{
@@ -1107,7 +1135,7 @@ func TestAccAWSProvider_IgnoreTags_Keys_One(t *testing.T) {
11071135

11081136
resource.ParallelTest(t, resource.TestCase{
11091137
PreCheck: func() { testAccPreCheck(t) },
1110-
ProviderFactories: testAccProviderFactories(&providers),
1138+
ProviderFactories: testAccProviderFactoriesInternal(&providers),
11111139
CheckDestroy: nil,
11121140
Steps: []resource.TestStep{
11131141
{
@@ -1125,7 +1153,7 @@ func TestAccAWSProvider_IgnoreTags_Keys_Multiple(t *testing.T) {
11251153

11261154
resource.ParallelTest(t, resource.TestCase{
11271155
PreCheck: func() { testAccPreCheck(t) },
1128-
ProviderFactories: testAccProviderFactories(&providers),
1156+
ProviderFactories: testAccProviderFactoriesInternal(&providers),
11291157
CheckDestroy: nil,
11301158
Steps: []resource.TestStep{
11311159
{
@@ -1143,7 +1171,7 @@ func TestAccAWSProvider_Region_AwsChina(t *testing.T) {
11431171

11441172
resource.ParallelTest(t, resource.TestCase{
11451173
PreCheck: func() { testAccPreCheck(t) },
1146-
ProviderFactories: testAccProviderFactories(&providers),
1174+
ProviderFactories: testAccProviderFactoriesInternal(&providers),
11471175
CheckDestroy: nil,
11481176
Steps: []resource.TestStep{
11491177
{
@@ -1163,7 +1191,7 @@ func TestAccAWSProvider_Region_AwsCommercial(t *testing.T) {
11631191

11641192
resource.ParallelTest(t, resource.TestCase{
11651193
PreCheck: func() { testAccPreCheck(t) },
1166-
ProviderFactories: testAccProviderFactories(&providers),
1194+
ProviderFactories: testAccProviderFactoriesInternal(&providers),
11671195
CheckDestroy: nil,
11681196
Steps: []resource.TestStep{
11691197
{
@@ -1183,7 +1211,7 @@ func TestAccAWSProvider_Region_AwsGovCloudUs(t *testing.T) {
11831211

11841212
resource.ParallelTest(t, resource.TestCase{
11851213
PreCheck: func() { testAccPreCheck(t) },
1186-
ProviderFactories: testAccProviderFactories(&providers),
1214+
ProviderFactories: testAccProviderFactoriesInternal(&providers),
11871215
CheckDestroy: nil,
11881216
Steps: []resource.TestStep{
11891217
{
@@ -1203,7 +1231,7 @@ func TestAccAWSProvider_AssumeRole_Empty(t *testing.T) {
12031231

12041232
resource.ParallelTest(t, resource.TestCase{
12051233
PreCheck: func() { testAccPreCheck(t) },
1206-
ProviderFactories: testAccProviderFactories(&providers),
1234+
ProviderFactories: testAccProviderFactoriesInternal(&providers),
12071235
CheckDestroy: nil,
12081236
Steps: []resource.TestStep{
12091237
{

aws/resource_aws_backup_plan_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,9 @@ func TestAccAwsBackupPlan_Rule_CopyAction_CrossRegion(t *testing.T) {
436436
PreCheck: func() {
437437
testAccPreCheck(t)
438438
testAccPreCheckAWSBackup(t)
439-
testAccMultipleRegionsPreCheck(t)
440-
testAccAlternateRegionPreCheck(t)
439+
testAccMultipleRegionPreCheck(t, 2)
441440
},
442-
ProviderFactories: testAccProviderFactories(&providers),
441+
ProviderFactories: testAccProviderFactoriesAlternate(&providers),
443442
CheckDestroy: testAccCheckAwsBackupPlanDestroy,
444443
Steps: []resource.TestStep{
445444
{

aws/resource_aws_cloudfront_distribution_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -2538,10 +2538,8 @@ func testAccAWSCloudFrontDistributionConfigViewerCertificateAcmCertificateArnBas
25382538
key := tlsRsaPrivateKeyPem(2048)
25392539
certificate := tlsRsaX509SelfSignedCertificatePem(key, commonName)
25402540

2541-
return testAccUsEast1RegionProviderConfig() + fmt.Sprintf(`
2541+
return testAccCloudfrontRegionProviderConfig() + fmt.Sprintf(`
25422542
resource "aws_acm_certificate" "test" {
2543-
provider = "awsus-east-1"
2544-
25452543
certificate_body = "%[1]s"
25462544
private_key = "%[2]s"
25472545
}

aws/resource_aws_db_instance_test.go

+8-11
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func TestAccAWSDBInstance_DbSubnetGroupName_RamShared(t *testing.T) {
355355
testAccAlternateAccountPreCheck(t)
356356
testAccOrganizationsEnabledPreCheck(t)
357357
},
358-
ProviderFactories: testAccProviderFactories(&providers),
358+
ProviderFactories: testAccProviderFactoriesAlternate(&providers),
359359
CheckDestroy: testAccCheckAWSDBInstanceDestroy,
360360
Steps: []resource.TestStep{
361361
{
@@ -778,10 +778,9 @@ func TestAccAWSDBInstance_ReplicateSourceDb_DbSubnetGroupName(t *testing.T) {
778778
resource.ParallelTest(t, resource.TestCase{
779779
PreCheck: func() {
780780
testAccPreCheck(t)
781-
testAccMultipleRegionsPreCheck(t)
782-
testAccAlternateRegionPreCheck(t)
781+
testAccMultipleRegionPreCheck(t, 2)
783782
},
784-
ProviderFactories: testAccProviderFactories(&providers),
783+
ProviderFactories: testAccProviderFactoriesAlternate(&providers),
785784
CheckDestroy: testAccCheckAWSDBInstanceDestroy,
786785
Steps: []resource.TestStep{
787786
{
@@ -808,12 +807,11 @@ func TestAccAWSDBInstance_ReplicateSourceDb_DbSubnetGroupName_RamShared(t *testi
808807
resource.ParallelTest(t, resource.TestCase{
809808
PreCheck: func() {
810809
testAccPreCheck(t)
811-
testAccMultipleRegionsPreCheck(t)
812-
testAccAlternateRegionPreCheck(t)
810+
testAccMultipleRegionPreCheck(t, 2)
813811
testAccAlternateAccountPreCheck(t)
814812
testAccOrganizationsEnabledPreCheck(t)
815813
},
816-
ProviderFactories: testAccProviderFactories(&providers),
814+
ProviderFactories: testAccProviderFactoriesAlternateAccountAndAlternateRegion(&providers),
817815
CheckDestroy: testAccCheckAWSDBInstanceDestroy,
818816
Steps: []resource.TestStep{
819817
{
@@ -840,10 +838,9 @@ func TestAccAWSDBInstance_ReplicateSourceDb_DbSubnetGroupName_VpcSecurityGroupId
840838
resource.ParallelTest(t, resource.TestCase{
841839
PreCheck: func() {
842840
testAccPreCheck(t)
843-
testAccMultipleRegionsPreCheck(t)
844-
testAccAlternateRegionPreCheck(t)
841+
testAccMultipleRegionPreCheck(t, 2)
845842
},
846-
ProviderFactories: testAccProviderFactories(&providers),
843+
ProviderFactories: testAccProviderFactoriesAlternate(&providers),
847844
CheckDestroy: testAccCheckAWSDBInstanceDestroy,
848845
Steps: []resource.TestStep{
849846
{
@@ -1443,7 +1440,7 @@ func TestAccAWSDBInstance_SnapshotIdentifier_DbSubnetGroupName_RamShared(t *test
14431440
testAccAlternateAccountPreCheck(t)
14441441
testAccOrganizationsEnabledPreCheck(t)
14451442
},
1446-
ProviderFactories: testAccProviderFactories(&providers),
1443+
ProviderFactories: testAccProviderFactoriesAlternate(&providers),
14471444
CheckDestroy: testAccCheckAWSDBInstanceDestroy,
14481445
Steps: []resource.TestStep{
14491446
{

aws/resource_aws_dynamodb_table_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ func TestAccAWSDynamoDbTable_Replica_Multiple(t *testing.T) {
14021402
testAccPreCheck(t)
14031403
testAccMultipleRegionPreCheck(t, 3)
14041404
},
1405-
ProviderFactories: testAccProviderFactories(&providers),
1405+
ProviderFactories: testAccProviderFactoriesMultipleRegion(&providers, 3),
14061406
CheckDestroy: testAccCheckAWSDynamoDbTableDestroy,
14071407
Steps: []resource.TestStep{
14081408
{
@@ -1447,7 +1447,7 @@ func TestAccAWSDynamoDbTable_Replica_Single(t *testing.T) {
14471447
testAccPreCheck(t)
14481448
testAccMultipleRegionPreCheck(t, 2)
14491449
},
1450-
ProviderFactories: testAccProviderFactories(&providers),
1450+
ProviderFactories: testAccProviderFactoriesMultipleRegion(&providers, 3), // 3 due to shared test configuration
14511451
CheckDestroy: testAccCheckAWSDynamoDbTableDestroy,
14521452
Steps: []resource.TestStep{
14531453
{

0 commit comments

Comments
 (0)