Skip to content

fix(dynamodb): use concrete ARN account/region when resourceName is tokenized - #38485

Open
sanyamk23 wants to merge 2 commits into
aws:mainfrom
sanyamk23:fix/dynamodb-table-v2-partial-arn-validation
Open

fix(dynamodb): use concrete ARN account/region when resourceName is tokenized#38485
sanyamk23 wants to merge 2 commits into
aws:mainfrom
sanyamk23:fix/dynamodb-table-v2-partial-arn-validation

Conversation

@sanyamk23

Copy link
Copy Markdown

Description

The previous broad Token.isUnresolved(tableArn) guard in validateMultiAccountReplica skipped the splitArn extraction whenever any part of the source table ARN was tokenized — even if only the resourceName was a token with concrete account and region parts.

This caused sourceAccount and sourceRegion to fall back to the stack that owns the imported resource (often the same as the replica stack), which falsely triggered the MultiAccountReplicaMustBeDifferentAccount and MultiAccountReplicaMustBeDifferentRegion errors for imported tables whose ARN had a tokenized table name.

Changes

  • packages/aws-cdk-lib/aws-dynamodb/lib/table-v2.ts: Always call splitArn; use the extracted account/region whenever they are concrete (not tokens), falling back to the stack's values only when the ARN's corresponding part is itself a token.
  • packages/aws-cdk-lib/aws-dynamodb/test/table-v2.test.ts: New test asserting no false-positive error when the source table ARN has a concrete account/region but a tokenized resourceName (string-concatenated from Lazy.string).

Backwards compatibility

Additive — the previous behavior only changed the extracted values when the entire ARN was fully concrete, which made validation tighter than intended (false errors). The new behavior extracts concrete components whenever possible and per-field checks still skip validation when a part is a token — preserving the documented "skip if token" behavior at the per-field level.

Closes #38354

🤖🤖🤖 Generated with AI - this code was authored with the help of an AI agent.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.

@github-actions github-actions Bot added bug This issue is a bug. effort/small Small work item – less than a day of effort p1 labels Aug 3, 2026
@aws-cdk-automation
aws-cdk-automation requested a review from a team August 3, 2026 14:06
@github-actions github-actions Bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

👋 It looks like your PR description references an issue, but not in the expected location.

The issue number must appear in the first section of the description (the first two lines), following the template format:

### Issue # (if applicable)

Closes #123.

Please move your issue reference to the top of the description.

@aws-cdk-automation aws-cdk-automation left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

…okenized

The previous broad `Token.isUnresolved(tableArn)` guard in
`validateMultiAccountReplica` skipped splitArn extraction whenever any
part of the source table ARN was tokenized, even if just the resourceName
was a token with concrete account and region components. This caused
`sourceAccount` and `sourceRegion` to fall back to the stack that owns
the imported resource (often the same as the replica stack), which
falsely triggered the `MultiAccountReplicaMustBeDifferentAccount` and
`MultiAccountReplicaMustBeDifferentRegion` errors for imported tables
whose ARN had a tokenized table name.

Now `splitArn` is always called and the extracted account/region are
used whenever they are concrete, falling back to the stack's values only
when the ARN's corresponding part is itself a token.

Closes aws#38354

🤖🤖🤖 Generated with AI - this code was authored with the help of an AI agent
@sanyamk23
sanyamk23 force-pushed the fix/dynamodb-table-v2-partial-arn-validation branch from 3ada80b to eba4d7f Compare August 3, 2026 17:43
…tReplica

Add integration test case that exercises the fix for extracting
concrete account/region from ARNs when resourceName is tokenized.
Includes updated snapshot with the new ReplicaPartial GlobalTable resource.
@aws-cdk-automation
aws-cdk-automation dismissed their stale review August 3, 2026 20:30

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(dynamodb): TableV2 validateMultiAccountReplica fails for imported table with tokenized ARN

2 participants