-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Describe the bug
In f35b70b, a new policy statement was introduced to add permissions 'dynamodb:DeleteTable', 'dynamodb:DeleteTableReplica'
to allow for custom resource to delete the replication Table. However the resource arn was hardcoded to the aws
partition meaning that this code will not work in other partitions such as aws-cn
. (See Line 100 below)
aws-cdk/packages/aws-cdk-lib/aws-dynamodb/lib/replica-provider.ts
Lines 97 to 108 in 04323c4
// Required for replica table deletion | |
let resources: string[] = []; | |
props.regions.forEach((region) => { | |
resources.push(`arn:aws:dynamodb:${region}:${this.account}:table/${props.tableName}`); | |
}); | |
this.onEventHandler.addToRolePolicy( | |
new iam.PolicyStatement({ | |
actions: ['dynamodb:DeleteTable', 'dynamodb:DeleteTableReplica'], | |
resources: resources, | |
}), | |
); |
The error we see when the CDK stack is deployed to CN:
Partition "aws" is not valid for resource "arn:aws:dynamodb:cn-northwest-1:1234567890:table/MyTable". (Service: AmazonIdentityManagement; Status Code: 400; Error Code: MalformedPolicyDocument; Request ID: -snip-; Proxy: null)
Expected Behavior
The policy should be create inferring the partition when specifying the tableArn for the resource of the new policy statement.
Current Behavior
The policy creation fails in CN partition as the partition is hardcoded to standard partition.
Reproduction Steps
- Create a CDK repo that only has 1
Table
resource. - As part of the Table resource provide
replicationRegions
and have eithercn-north-1
orcn-northwest-1
. - Synth the repo and attempt to deploy the stack to China
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.73.0
Framework Version
No response
Node.js Version
18.0.0
OS
Linux
Language
Typescript
Language Version
No response
Other information
No response