-
Notifications
You must be signed in to change notification settings - Fork 4k
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_dynamodb: Table grant inconsistencies #20105
Comments
thanks for opening the issue. The reason the Note that the KMS Key has a resource policy, which can be made to trust that Principal, but DynamoDB Tables do not have a resource policy. Did you perhaps want to use the Thanks, |
Hi Adam, Thanks for looking at this. In my exact use case I was attempting to grant Table permissions to a I have a list of roles that I want to grant permissions to. If I loop over them we end up with lots of duplication in the policy that seems unnecessary at best, and has the potential to cause the policy to bump against the hard PolicySize quota at worst. All that said, it seems wrong that the types at play here imply I would be able to use an Thanks again for looking at this, |
Unfortunately, things are a little complex, as you've seen, so failing is probably not a good idea 🙂. Can you make sure you're on a version no earlier than 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. |
@skinny85 -- sorry for the late reply. That feature flag doesn't work for my use case because the merge does not happen on the e.g. this code: const table = new aws_dynamodb.Table(this, 'my-table', {
encryption: aws_dynamodb.TableEncryption.CUSTOMER_MANAGED,
partitionKey: {
name: 'id',
type: aws_dynamodb.AttributeType.STRING,
},
tableName: 'my-table-name',
});
const roleOne = aws_iam.Role.fromRoleArn(this, 'Role1', `arn:aws:iam::${accountId}:role/Role1`);
const roleTwo = aws_iam.Role.fromRoleArn(this, 'Role2', `arn:aws:iam::${accountId}:role/Role2`);
table.grantReadWriteData(roleOne);
table.grantReadWriteData(roleTwo); results in this synth'd template snippet: Role1Policy1275B564:
Type: AWS::IAM::Policy
Properties:
PolicyDocument:
Statement:
- Action:
- dynamodb:BatchGetItem
- dynamodb:BatchWriteItem
- dynamodb:ConditionCheckItem
- dynamodb:DeleteItem
- dynamodb:DescribeTable
- dynamodb:GetItem
- dynamodb:GetRecords
- dynamodb:GetShardIterator
- dynamodb:PutItem
- dynamodb:Query
- dynamodb:Scan
- dynamodb:UpdateItem
Effect: Allow
Resource:
- Fn::GetAtt:
- mytable0324D45C
- Arn
- Ref: AWS::NoValue
- Action:
- kms:Decrypt
- kms:DescribeKey
- kms:Encrypt
- kms:GenerateDataKey*
- kms:ReEncrypt*
Effect: Allow
Resource:
Fn::GetAtt:
- mytableKeyF511837D
- Arn
Version: "2012-10-17"
PolicyName: Role1Policy1275B564
Roles:
- Role1
Role2PolicyFB7A062B:
Type: AWS::IAM::Policy
Properties:
PolicyDocument:
Statement:
- Action:
- dynamodb:BatchGetItem
- dynamodb:BatchWriteItem
- dynamodb:ConditionCheckItem
- dynamodb:DeleteItem
- dynamodb:DescribeTable
- dynamodb:GetItem
- dynamodb:GetRecords
- dynamodb:GetShardIterator
- dynamodb:PutItem
- dynamodb:Query
- dynamodb:Scan
- dynamodb:UpdateItem
Effect: Allow
Resource:
- Fn::GetAtt:
- mytable0324D45C
- Arn
- Ref: AWS::NoValue
- Action:
- kms:Decrypt
- kms:DescribeKey
- kms:Encrypt
- kms:GenerateDataKey*
- kms:ReEncrypt*
Effect: Allow
Resource:
Fn::GetAtt:
- mytableKeyF511837D
- Arn
Version: "2012-10-17"
PolicyName: Role2PolicyFB7A062B
Roles:
- Role2 |
So, what's the problem here? Those are separate Policies, so which IAM quota are bumping against? |
It's certainly not optimal to have essentially identical Policies which only vary by the entity that they are being attached to. The specific concern is that we could potentially bump against the maximum policy size hard limit and also size limits for the stack itself. From the documentation:
|
I wouldn't worry about it - the template size & resource count limit (that's what I assume you mean by "Stack size limits") are pretty high, and it's unlikely these Policy resources would push the Stack above them, and merging the two Policies into one, referencing both Roles, has no effect on the total size of the Policies allowed for a single Role. Note also that you can always import the Role as immutable (https://docs.aws.amazon.com/cdk/api/v1/docs/aws-iam-readme.html#using-existing-roles), and the Policies would not be generated at all. But of course, that means the Roles need the correct |
Describe the bug
When attempting to grant table permissions to an
IPrincipal
, we expect those permissions to be added but they are silently ignored.Expected Behavior
Table permissions should be granted to any
IGrantable
.Current Behavior
Table permissions are not granted to
IPrincipal
s.Reproduction Steps
Example code:
Example synth'd template snippet:
You can see here that the
ArnPrincipal
is only granted KMS-related usage. It is ignored for the table permissions policy.Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.21.1 (build a6ee543)
Framework Version
No response
Node.js Version
v14.19.1
OS
Darwin Kernel Version 20.6.0: Tue Feb 22 21:10:41 PST 2022; root:xnu-7195.141.26~1/RELEASE_X86_64
Language
Typescript
Language Version
TypeScript (4.6.3)
Other information
No response
The text was updated successfully, but these errors were encountered: