-
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
feat(iam): implement IGrantable to Policy and ManagedPolicy #22712
Conversation
Pull request has been modified.
6861ad6
to
653b0a2
Compare
653b0a2
to
6b2b29d
Compare
I've marked as draft due to incomplete; i.e. |
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. |
2 similar comments
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. |
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. |
3 similar comments
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. |
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. |
@Tietew Is this still a draft? Was wondering just I just ran into the issue of ManagedPolicy not implementing IGrantable |
I researched usage of grant* methods. IAM group and IPrincipal
const stack1234 = new Stack(app, 'stack1234', { env: { account: '1234' } });
const group = new iam.Group(stack1234, 'group', { ... });
const mp = new iam.ManagedPolicy(stack1234, 'policy', { ... });
const stack5678 = new Stack(app, 'stack5678', { env: { account: '5678' } });
const s3 = new s3.Bucket(stack5678, 'bucket', { ... });
s3.grantRead(group); // fails: Cannot use an IAM Group as the 'Principal' or 'NotPrincipal' in an IAM Policy
s3.grantRead(mp); // should fail too!
list of grant* methods usagesimpleOnly
calls
|
@dan-lind Thank you for catching! It's ready now. |
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. |
Is there anything else that needs to be done here? I'm eagerly awaiting this functionality and I'd hate to see the PR languish. |
Is there anything the community can do to get this PR approved? I'm very excited to see the functionality added to CDK and I'm afraid that progress on it has stalled. |
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 looks really good, and hopefully we can merge it soon! I have a conceptual and cosmetic comments
} | ||
|
||
public get policyFragment(): PrincipalPolicyFragment { | ||
throw new Error(`Cannot use a ManagedPolicy ${this._managedPolicy.node.path} as the 'Principal' or 'NotPrincipal' in an IAM Policy`); |
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.
throw new Error(`Cannot use a ManagedPolicy ${this._managedPolicy.node.path} as the 'Principal' or 'NotPrincipal' in an IAM Policy`); | |
throw new Error(`Cannot use a ManagedPolicy '${this._managedPolicy.node.path}' as the 'Principal' or 'NotPrincipal' in an IAM Policy`); |
Can you add a comment above this error explaining why we need to throw it? It's not immediately clear
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.
I believe policyFragment
is currently the best location to raise an error when we try to add Policy/ManagedPolicy to a resource-based policy. Suggestions are welcome.
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.
@Tietew I know this is an old thread but I have a question wanting to understanding better.
You mentioned that PolicyStatement.validatePolicyPrincipal()
throws error for Group
. So why not update PolicyStatement.validatePolicyPrincipal()
to throw for Policy or Managed Policy as well?
Pull request has been modified.
@comcalvi Thank you for your review. updated. |
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.
Nice work!
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Fixes #10308
All Submissions:
Adding new Unconventional Dependencies:
New Features
yarn integ
to deploy the infrastructure and generate the snapshot (i.e.yarn integ
without--dry-run
)?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license