-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(dynamodb): replication regions are incompatible with resource policies in TableV2 #31097
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why this changes are needed to help me understand? What's the current behaviour and issue when setting the resoruce policies in the replication regions?
The issue is defined in #31097 Do you require more information than is supplied there? |
|
||
//const resourcePolicy = props.resourcePolicy ?? this.tableOptions.resourcePolicy; | ||
//const resourcePolicy = props.resourcePolicy; | ||
const resourcePolicy = (props.region === this.region ? this.tableOptions.resourcePolicy : props.resourcePolicy) || undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change for existing users. If existing users manage to bypass the CFN error by using escape hatch. They then remove the escape hatch and upgrade to a version that includes this change, their replication region will now have the resource policies removed, thus this is not an acceptable change. I would recommend you to do it following the suggested proposal in the original issue.
Ideally, the construct could allow null and when null is specified in a specific replica, no resourcePolicy is added to that replica even when one is defined in the TableV2 itself
new TableV2(this, `MyTable-${stage}`, {
pointInTimeRecovery: true,
partitionKey: {
name: 'key',
type: AttributeType.STRING,
},
tableName: 'MyTable',
// us-east-2 should not have tablePolicyDocument added in the template
replicas: [{ region: 'us-east-1' }, { region: 'us-east-2', resourcePolicy: null }],
resourcePolicy: tablePolicyDocument,
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is forcing a user to add null for when they don't want a resource policy. The default implementation should only require them to add a policy to a replica should the want it. It shouldn't default to adding it to all replicas.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM, some minor feedbacks on the integ tests.
new dynamodb.TableV2(this, 'TableTestV2', { | ||
partitionKey: { | ||
name: 'id', | ||
type: dynamodb.AttributeType.STRING, | ||
}, | ||
removalPolicy: RemovalPolicy.DESTROY, | ||
resourcePolicy: docu, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test doesn't seem to test for replica?
], | ||
"StreamSpecification": { | ||
"StreamViewType": "NEW_AND_OLD_IMAGES" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this change from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stream came from adding a replica.
table.addReplica({
region: 'eu-west-2',
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that's good to know.
table.addReplica({ | ||
region: 'eu-west-2', | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test didn't even set the feature flag, so my understanding is that it should use the table's resource policy but doesn't seem to be the case in the output template.json. May I ask how you ran the tests locally and update the snapshot?
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
1 similar comment
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week. |
Had some issues with building so pushed a fresh version #31513 |
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
Closes #30705
Reason for this change
Resource policies were shared across all replicas in a region.
Description of changes
Changed the logic to only apply resource policy to the local replica region, or to specific replicas only when defined.
Description of how you validated changes
Unit tests were conducted
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license