Skip to content

Commit

Permalink
Merge pull request #16965 from hashicorp/t-gov-hardreg-dynamodb
Browse files Browse the repository at this point in the history
tests/resource/dynamodb_global_table: Fix hardcoded regions
  • Loading branch information
YakDriver authored Jan 7, 2021
2 parents 662e995 + 2054399 commit 21f6b67
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion aws/resource_aws_dynamodb_global_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand Down Expand Up @@ -159,8 +160,21 @@ func testAccPreCheckAWSDynamodbGlobalTable(t *testing.T) {
}

// testAccDynamoDBGlobalTablePreCheck checks if aws_dynamodb_global_table (version 2017.11.29) can be used and skips test if not.
// Region availability for Version 2017.11.29: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GlobalTables.html
func testAccDynamoDBGlobalTablePreCheck(t *testing.T) {
supportRegionsSort := []string{"ap-northeast-1", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "eu-central-1", "eu-west-1", "eu-west-2", "us-east-1", "us-east-2", "us-west-1", "us-west-2"}
supportRegionsSort := []string{
endpoints.ApNortheast1RegionID,
endpoints.ApNortheast2RegionID,
endpoints.ApSoutheast1RegionID,
endpoints.ApSoutheast2RegionID,
endpoints.EuCentral1RegionID,
endpoints.EuWest1RegionID,
endpoints.EuWest2RegionID,
endpoints.UsEast1RegionID,
endpoints.UsEast2RegionID,
endpoints.UsWest1RegionID,
endpoints.UsWest2RegionID,
}

if testAccGetRegion() != supportRegionsSort[sort.SearchStrings(supportRegionsSort, testAccGetRegion())] {
t.Skipf("skipping test; aws_dynamodb_global_table (DynamoDB v2017.11.29) not supported in region %s", testAccGetRegion())
Expand Down

0 comments on commit 21f6b67

Please sign in to comment.