Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d1c96a0
dynamodb: Fix Multi-Region Strong Consistency (MRSC) implementation a…
Jun 5, 2025
e992248
Add support for Multi Region Strong Consistency
shawnaws Jun 23, 2025
e977da7
Add support for Multi Region Strong Consistency
shawnaws Jun 25, 2025
3c886a2
Finish test updates
shawnaws Jun 27, 2025
01cbd96
Add changelog for DDB MRSC
shawnaws Jun 30, 2025
548d3ab
Merge branch 'main' into f/ddb-mrsc
shawnaws Jun 30, 2025
7d2b080
Reverting go.mod and go.sum
shawnaws Jun 30, 2025
3195d83
Fixing terrafmt and go test build failures
shawnaws Jul 1, 2025
35155ff
fixing golangci-lint and website checks
shawnaws Jul 1, 2025
61696e1
fixing golangci-lint and website checks
shawnaws Jul 1, 2025
f19c70f
fixing golangci-lint
shawnaws Jul 1, 2025
229d0f1
Fixing golangci-lint, providerlint, update tests for GA support
shawnaws Jul 1, 2025
5248c2f
Update website/docs/r/dynamodb_table.html.markdown
shawnaws Jul 2, 2025
a239bd1
Update website/docs/r/dynamodb_table.html.markdown
shawnaws Jul 2, 2025
c5c4408
Rem neg test w/unsupported regions. will be handled by normal error flow
shawnaws Jul 2, 2025
f468cac
Merge branch 'main' into HEAD
ewbankkit Jul 2, 2025
5109c35
Tweak CHANGELOG entry.
ewbankkit Jul 2, 2025
99b38a1
Cosmetics.
ewbankkit Jul 7, 2025
744254e
Fix spelling.
ewbankkit Jul 7, 2025
073fb65
Fix 'TestAccDynamoDBTable_Replica_MRSC_TooManyReplicas'.
ewbankkit Jul 8, 2025
7cc2de9
r/aws_dynamodb_table: Change 'replica.consistency_mode' to Computed.
ewbankkit Jul 8, 2025
4839bb9
Revert "r/aws_dynamodb_table: Change 'replica.consistency_mode' to Co…
ewbankkit Jul 8, 2025
e421c7f
Add 'TestAccDynamoDBTable_Replica_upgradeV6_2_0'.
ewbankkit Jul 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/43236.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_dynamodb_table: Add `replica.consistency_mode` argument in support of [multi-Region strong consistency](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/V2globaltables_HowItWorks.html#V2globaltables_HowItWorks.choosing-consistency-mode) for Amazon DynamoDB global tables
```
55 changes: 55 additions & 0 deletions internal/acctest/acctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ const (
// Provider name for third configuration testing
ProviderNameThird = "awsthird"

// Provider name for fourth configuration testing
ProviderNameFourth = "awsfourth"

ResourcePrefix = "tf-acc-test"

CertificateIssueTimeout = 5 * time.Minute
Expand Down Expand Up @@ -284,6 +287,8 @@ func ProtoV5FactoriesMultipleRegions(ctx context.Context, t *testing.T, n int) m
return protoV5ProviderFactoriesInit(ctx, ProviderName, ProviderNameAlternate)
case 3:
return protoV5ProviderFactoriesInit(ctx, ProviderName, ProviderNameAlternate, ProviderNameThird)
case 4:
return protoV5ProviderFactoriesInit(ctx, ProviderName, ProviderNameAlternate, ProviderNameThird, ProviderNameFourth)
default:
t.Fatalf("invalid number of Region configurations: %d", n)
}
Expand Down Expand Up @@ -917,6 +922,10 @@ func ThirdRegion() string {
return envvar.GetWithDefault(envvar.ThirdRegion, endpoints.UsEast2RegionID)
}

func FourthRegion() string {
return envvar.GetWithDefault(envvar.FourthRegion, endpoints.UsWest1RegionID)
}

func Partition() string {
return names.PartitionForRegion(Region()).ID()
}
Expand All @@ -941,6 +950,10 @@ func thirdRegionPartition() string {
return names.PartitionForRegion(ThirdRegion()).ID()
}

func fourthRegionPartition() string {
return names.PartitionForRegion(FourthRegion()).ID()
}

func PreCheckAlternateAccount(t *testing.T) {
t.Helper()

Expand All @@ -961,6 +974,17 @@ func PreCheckThirdAccount(t *testing.T) {
}
}

// add fourth region
func PreCheckFourthAccount(t *testing.T) {
t.Helper()

envvar.SkipIfAllEmpty(t, []string{envvar.FourthProfile, envvar.FourthAccessKeyId}, "credentials for running acceptance testing in fourth AWS account")

if os.Getenv(envvar.FourthAccessKeyId) != "" {
envvar.SkipIfEmpty(t, envvar.FourthSecretAccessKey, "static credentials value when using "+envvar.FourthAccessKeyId)
}
}

func PreCheckPartitionHasService(t *testing.T, serviceID string) {
t.Helper()

Expand Down Expand Up @@ -1002,6 +1026,28 @@ func PreCheckMultipleRegion(t *testing.T, regions int) {
if Partition() != thirdRegionPartition() {
t.Fatalf("%s partition (%s) does not match %s partition (%s)", envvar.ThirdRegion, thirdRegionPartition(), envvar.DefaultRegion, Partition())
}

if regions == 4 {
if fourthRegionPartition() == endpoints.AwsUsGovPartitionID || Partition() == endpoints.AwsUsGovPartitionID {
t.Skipf("wanted %d regions, partition (%s) only has 2 regions", regions, Partition())
}

if Region() == FourthRegion() {
t.Fatalf("%s and %s must be set to different values for acceptance tests", envvar.DefaultRegion, envvar.FourthRegion)
}

if AlternateRegion() == FourthRegion() {
t.Fatalf("%s and %s must be set to different values for acceptance tests", envvar.AlternateRegion, envvar.FourthRegion)
}

if ThirdRegion() == FourthRegion() {
t.Fatalf("%s and %s must be set to different values for acceptance tests", envvar.ThirdRegion, envvar.FourthRegion)
}

if Partition() != fourthRegionPartition() {
t.Fatalf("%s partition (%s) does not match %s partition (%s)", envvar.FourthRegion, fourthRegionPartition(), envvar.DefaultRegion, Partition())
}
}
}

if partition, ok := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), Region()); ok {
Expand Down Expand Up @@ -1047,6 +1093,15 @@ func PreCheckThirdRegion(t *testing.T, regions ...string) {
}
}

// PreCheckFourthRegion checks that the fourth test region is one of the specified AWS Regions.
func PreCheckFourthRegion(t *testing.T, regions ...string) {
t.Helper()

if curr := FourthRegion(); !slices.Contains(regions, curr) {
t.Skipf("skipping tests; %s (%s) not supported. Supported: [%s]", envvar.FourthRegion, curr, strings.Join(regions, ", "))
}
}

// PreCheckPartition checks that the test partition is the specified partition.
func PreCheckPartition(t *testing.T, partition string) {
t.Helper()
Expand Down
16 changes: 15 additions & 1 deletion internal/acctest/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ func ConfigMultipleAccountProvider(t *testing.T, accounts int) string {
),
)
}
if accounts == 4 {
config.WriteString(
ConfigNamedAccountProvider(
ProviderNameFourth,
os.Getenv(envvar.FourthAccessKeyId),
os.Getenv(envvar.FourthProfile),
os.Getenv(envvar.FourthSecretAccessKey),
),
)
}

return config.String()
}
Expand Down Expand Up @@ -95,10 +105,14 @@ func ConfigMultipleRegionProvider(regions int) string {

config.WriteString(ConfigNamedRegionalProvider(ProviderNameAlternate, AlternateRegion()))

if regions >= 3 {
if regions == 3 {
config.WriteString(ConfigNamedRegionalProvider(ProviderNameThird, ThirdRegion()))
}

if regions == 4 {
config.WriteString(ConfigNamedRegionalProvider(ProviderNameFourth, FourthRegion()))
}

return config.String()
}

Expand Down
11 changes: 11 additions & 0 deletions internal/acctest/knownvalue/regional_arn_exact.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,14 @@ func RegionalARNThirdRegionExact(service, resource string) knownvalue.Check {
resource: resource,
}
}

// RegionalARNExact is a known value check that ensures the value is a string
// that matches the expected ARN for the given service and resource.
func RegionalARNFourthExact(service, resource string) knownvalue.Check {
return regionalARNExact{
check: "RegionalARNFourthRegionExact",
region: acctest.FourthRegion(),
service: service,
resource: resource,
}
}
10 changes: 10 additions & 0 deletions internal/acctest/knownvalue/regional_arn_regexp.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ func RegionalARNThirdRegionRegexp(service string, resource *regexp.Regexp) known
}
}

// RegionalARNFourthRegionRegexp
func RegionalARNFourthRegionRegexp(service string, resource *regexp.Regexp) knownvalue.Check {
return regionalARNRegexp{
check: "RegionalARNFourthRegionRegexp",
region: acctest.FourthRegion(),
service: service,
resourceRegexp: resource,
}
}

func RegionalARNRegexpRegion(service, region string, resource *regexp.Regexp) knownvalue.Check {
return regionalARNRegexp{
check: "RegionalARNRegexp",
Expand Down
12 changes: 12 additions & 0 deletions internal/envvar/envvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ const (
// For tests using a third AWS account, the equivalent of AWS_SECRET_ACCESS_KEY for that account
ThirdSecretAccessKey = "AWS_THIRD_SECRET_ACCESS_KEY"

// For tests using a fourth AWS account, the equivalent of AWS_ACCESS_KEY_ID for that account
FourthAccessKeyId = "AWS_FOURTH_ACCESS_KEY_ID"

// For tests using a fourth AWS account, the equivalent of AWS_PROFILE for that account
FourthProfile = "AWS_FOURTH_PROFILE"

// For tests using a fourth AWS region, the equivalent of AWS_DEFAULT_REGION for that region
FourthRegion = "AWS_FOURTH_REGION"

// For tests using a fourth AWS account, the equivalent of AWS_SECRET_ACCESS_KEY for that account
FourthSecretAccessKey = "AWS_FOURTH_SECRET_ACCESS_KEY"

// For tests requiring GitHub permissions
GithubToken = "GITHUB_TOKEN"

Expand Down
Loading
Loading