Skip to content

Commit 10de047

Browse files
authored
fix(dynamodb): unsupported actions added to table resource policy (#36228)
### Issue # (if applicable) Closes #32230. ### Reason for this change `Table` and `TableV2` were adding actions `GetShardItem` and `GetRecord` to the table's resource policy for cross-account resources, service and account principals. The issue is that these actions are not supported in the resource policies. Hence creating a deployment failure ### Description of changes Separated these actions to only be added to the IAM principal, but not the resource for `Table` and `TableV2` constructs. ### Describe any new or updated permissions being added No new permissions are added. The `GetShardItem` and `GetRecord` permissions are removed for resource policies. ### Description of how you validated changes Unit and Integration tests have been modified. The integration test failed to deploy before the fix, but now it succeeds after this fix. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 5cb99a5 commit 10de047

File tree

20 files changed

+1337
-346
lines changed

20 files changed

+1337
-346
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.policy.js.snapshot/ResourcePolicyTest-v2.assets.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.policy.js.snapshot/ResourcePolicyTest-v2.template.json

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
],
1919
"Replicas": [
2020
{
21-
"Region": "eu-west-1",
21+
"Region": {
22+
"Ref": "AWS::Region"
23+
},
2224
"ResourcePolicy": {
2325
"PolicyDocument": {
2426
"Statement": [
@@ -30,7 +32,11 @@
3032
"Fn::Join": [
3133
"",
3234
[
33-
"arn:aws:iam::",
35+
"arn:",
36+
{
37+
"Ref": "AWS::Partition"
38+
},
39+
":iam::",
3440
{
3541
"Ref": "AWS::AccountId"
3642
},
@@ -50,6 +56,70 @@
5056
},
5157
"UpdateReplacePolicy": "Delete",
5258
"DeletionPolicy": "Delete"
59+
},
60+
"TableTestV22DC2AC9BC": {
61+
"Type": "AWS::DynamoDB::GlobalTable",
62+
"Properties": {
63+
"AttributeDefinitions": [
64+
{
65+
"AttributeName": "id",
66+
"AttributeType": "S"
67+
}
68+
],
69+
"BillingMode": "PAY_PER_REQUEST",
70+
"KeySchema": [
71+
{
72+
"AttributeName": "id",
73+
"KeyType": "HASH"
74+
}
75+
],
76+
"Replicas": [
77+
{
78+
"Region": {
79+
"Ref": "AWS::Region"
80+
},
81+
"ResourcePolicy": {
82+
"PolicyDocument": {
83+
"Statement": [
84+
{
85+
"Action": [
86+
"dynamodb:BatchGetItem",
87+
"dynamodb:ConditionCheckItem",
88+
"dynamodb:DescribeTable",
89+
"dynamodb:GetItem",
90+
"dynamodb:Query",
91+
"dynamodb:Scan"
92+
],
93+
"Effect": "Allow",
94+
"Principal": {
95+
"AWS": {
96+
"Fn::Join": [
97+
"",
98+
[
99+
"arn:",
100+
{
101+
"Ref": "AWS::Partition"
102+
},
103+
":iam::",
104+
{
105+
"Ref": "AWS::AccountId"
106+
},
107+
":root"
108+
]
109+
]
110+
}
111+
},
112+
"Resource": "*"
113+
}
114+
],
115+
"Version": "2012-10-17"
116+
}
117+
}
118+
}
119+
]
120+
},
121+
"UpdateReplacePolicy": "Retain",
122+
"DeletionPolicy": "Retain"
53123
}
54124
},
55125
"Parameters": {

packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.policy.js.snapshot/cdk.out

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-dynamodb/test/integ.dynamodb-v2.policy.js.snapshot/integ.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)