-
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
(@aws-cdk/aws-dynamodb): DynamoDb Replication: Cannot exceed quota for PoliciesPerRole: 10 #13671
Comments
How many tables and replica regions do you have in your stack? |
@jogold I have 11 tables and 9 of them are replicated in another region as well |
I just want to understand the exact numbers here... From what I see, we create 2 Policies, yes, but we attach them to different Roles: aws-cdk/packages/@aws-cdk/aws-dynamodb/lib/table.ts Lines 1473 to 1474 in aa45ede
@reinismu can you clarify your answer a little bit? Because I don't exactly follow. Can you show the Thanks, |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Sorry, missed the comment. const episodesTable = new Table(this, `${PREFIX}-series`, {
partitionKey: {
name: 'seriesId',
type: AttributeType.STRING,
},
tableName: `${PREFIX}-series`,
billingMode: BillingMode.PAY_PER_REQUEST,
replicationRegions: replicationRegions,
removalPolicy: REMOVAL_POLICY,
pointInTimeRecovery,
}); I have in total 9 tables with replicationRegions
|
Sorry, to clarify: you have 9 separate |
Yes :) |
Interesting! I just tried this: class ExampleStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
for (let i = 1; i <= 9; i++) {
new dynamodb.Table(this, `Table${i}`, {
partitionKey: {
name: 'Id',
type: dynamodb.AttributeType.STRING,
},
replicationRegions: ['eu-central-1', 'ap-southeast-1'],
removalPolicy: cdk.RemovalPolicy.DESTROY,
});
}
}
}
const app = new cdk.App();
new ExampleStack(app, 'ExampleStack'); and it deployed successfully! Can you try it on your end? Maybe the error is somewhere else? Thanks, |
Not sure what's wrong, but your example doesn't work for me.
Can you try increasing 9 to 15 or something. Just to check. I upgraded my main infra stack to |
Hmm, that's very concerning. That error shouldn't happen for a such a simple template. Can you push to a GitHub repo the minimal reproduction that makes you see that error? I'm curious what is causing it. |
I figured it out, Tho more by luck than error message. My main region is I'm deploying the example project and will try to break it now |
Aha got it! I deployed first with Not sure if deploying it 2x does anything, but can try |
OK, at least I was able to reproduce the |
…pendencies" When creating the Custom Resources that implement the global tables functionality, we add dependencies between them, as you can't create replicas of the same Table concurrently. However, if the Stack the Table is part of is env-agnostic, we also add a CFN Condition to the Custom Resource that checks whether the given region is the deployed-to region, and skip creating the replica in that case (as the Table itself acts as the replica in this case). But that Condition is not compatible with the dependency clause, as the resource will not exist if the Condition is false. Use a trick, and instead of using a DependsOn, add a CFN metadata that refers to the other Custom Resource through a Ref expression, which adds an implicit dependency, and wrap the entire Metadata in a Fn::If, guarded by the same Condition the other Custom Resource uses. Noticed by a customer in aws#13671 (comment).
First part of the fix: #13889 |
…esource dependencies" error (#13889) When creating the Custom Resources that implement the global tables functionality, we add dependencies between them, as you can't create replicas of the same Table concurrently. However, if the Stack the Table is part of is env-agnostic, we also add a CFN Condition to the Custom Resource that checks whether the given region is the deployed-to region, and skip creating the replica in that case (as the Table itself acts as the replica in this case). But that Condition is not compatible with the dependency clause, as the resource will not exist if the Condition is false. Use a trick, and instead of using a DependsOn, add a CFN metadata that refers to the other Custom Resource through a Ref expression, which adds an implicit dependency, and wrap the entire Metadata in a Fn::If, guarded by the same Condition the other Custom Resource uses. Noticed by a customer in #13671 (comment). ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…esource dependencies" error (aws#13889) When creating the Custom Resources that implement the global tables functionality, we add dependencies between them, as you can't create replicas of the same Table concurrently. However, if the Stack the Table is part of is env-agnostic, we also add a CFN Condition to the Custom Resource that checks whether the given region is the deployed-to region, and skip creating the replica in that case (as the Table itself acts as the replica in this case). But that Condition is not compatible with the dependency clause, as the resource will not exist if the Condition is false. Use a trick, and instead of using a DependsOn, add a CFN metadata that refers to the other Custom Resource through a Ref expression, which adds an implicit dependency, and wrap the entire Metadata in a Fn::If, guarded by the same Condition the other Custom Resource uses. Noticed by a customer in aws#13671 (comment). ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Yep, I was able to reproduce the original error with 11 Tables (not sure how you're getting it with just 9, but that's besides the point). The problem is the Roles for the Custom Resource framework handlers. We create a separate Policy for each replicated Table, and attach all of them to those Roles, here: aws-cdk/packages/@aws-cdk/aws-dynamodb/lib/table.ts Lines 1473 to 1474 in 93dac4c
This is a tough one... I think the only way to do this properly is to somehow count how many @reinismu for now, I would split the resources into multiple Stacks, so that no Stack has more than 10 Tables with replicas. @jogold any ideas on how to handle this? |
I wonder whether the logic of counting to 10 can be nicely encapsulated in the aws-cdk/packages/@aws-cdk/aws-dynamodb/lib/replica-provider.ts Lines 28 to 32 in 93dac4c
Also, I think I found another potential error with this feature: today, |
You are correct. What do you suggest here? Should we throw if a different value is set on a second table? Include the value in the |
Not a really a fan of this counting solution but I can't think of another one... Implementing it in |
Could ask CloudFormation team why there is this limit? Maybe it's not that hard to get rid of it. |
It's an IAM limit: Managed policies attached to an IAM role https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html You can request to increase it to 20. |
Ohh I see, I guess no way around that then. Even if I request it to 20 there would still be someone who will encounter this issue :/ |
Probably including the value of |
@jogold is there any way we can do a similar trick that you're doing right now, just with inline policies except managed policies? Since there is no limit on the number of inline policies. Maybe change the logical ID of the inline policy based on the properties of the Table that can cause replacement? Would that work? |
This should be possible but would restrict users from using tokens in those properties? |
Yeah, you're right, it wouldn't be as fool-proof as the current trick... I guess counting to 10 is the way to go here! |
Actually we cannot do this. For users already using a timeout if we include it in the uid it will impact the logical ID of the Lambda backing the custom resource. This means that the service token of the custom resource must be updated and this is not allowed in CF. No problem for counting to 10 because we can maintain the existing uid (and thus logical ids) up to 10: see #14054 |
The custom resource implementation uses IAM managed policies. There's a limit of 10 managed policies per role in IAM. Create a new provider if we reach the limit. Closes aws#13671
Seems like I'm stuck at the old version for my project :/ |
…esource dependencies" error (aws#13889) When creating the Custom Resources that implement the global tables functionality, we add dependencies between them, as you can't create replicas of the same Table concurrently. However, if the Stack the Table is part of is env-agnostic, we also add a CFN Condition to the Custom Resource that checks whether the given region is the deployed-to region, and skip creating the replica in that case (as the Table itself acts as the replica in this case). But that Condition is not compatible with the dependency clause, as the resource will not exist if the Condition is false. Use a trick, and instead of using a DependsOn, add a CFN metadata that refers to the other Custom Resource through a Ref expression, which adds an implicit dependency, and wrap the entire Metadata in a Fn::If, guarded by the same Condition the other Custom Resource uses. Noticed by a customer in aws#13671 (comment). ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Just ran into this today; leaving comment to avoid issue auto-closing. |
Try setting |
I have more than 10 tables with db replication and got the same error... |
Just ran into increased 20 limit. @aws-cdk/aws-iam:minimizePolicies does not help. |
Anyone was able to fix this? We are experiencing the same problem and because the problem is currently on already created stack we are unable to split it on multiple stacks. Any help would be greatly appreciated |
Running into this as well... having to split my persistence into different stacks because of such an arbitrary low limit is extremely unfortunate. |
This issue was for the existing Instead, the Be aware that there are additional deployment steps involved in a migration from Here are some other resources to get you started (using
|
Starting from version 1.92.0 I can't deploy my global tables.
#13300 seems like this is the change that introduced this bug for me.
Reproduction Steps
What did you expect to happen?
What actually happened?
Environment
Other
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: