-
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
iam: Grants only work on IAM objects, not arbitrary principals #236
Comments
This came up in #49 |
Came up again while wanting to write the following code:
Doesn't work, because AccountPrincipal is not an IAM object. |
And it should do something different for cross-account permissions (add to both resource and identity). |
Came up again when @leepa was working on a workshop: bucket.grantRead(new ArnPrincipal("arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity " + webDistribution.getId())); |
Another one that came up on Gitter:
Again a principal that is not an IAM identity, but a virtual thing which means the resource policy needs updatin'. |
Is there any workarounds w.r.t. to this? Like adding it through the SDK/CLI in a post-hook? :/ |
Add support for non-identity Principals in grants (for example, principals that represent accounts or organization IDs). For resources that support them, the required IAM statements will be added to the resource policy. For resources that don't support them (because they don't have resource policies) an error will be thrown. Add a new `OrganizationPrincipal` principal which represents all identities in the given AWS Organization. Fixes #236.
Add support for non-identity Principals in grants (for example, principals that represent accounts or organization IDs). For resources that support them, the required IAM statements will be added to the resource policy. For resources that don't support them (because they don't have resource policies) an error will be thrown. Add a new `OrganizationPrincipal` principal which represents all identities in the given AWS Organization. Grant methods no longer accept an optional principal. Instead, they accept an `IGrantable`, which encodes constructs that have a principal to grant to. This principal must be always present, but may be a principal that can't do any work other than emitting warnings for imported resources. For construct authors, all grant methods must now return an `iam.Grant` object, and all should be implemented by calling one of the static factory methods on `iam.Grant` and returning its result. Fixes #236. BREAKING CHANGE: `grant(function.role)` and `grant(project.role)` are now `grant(function)` and `grant(role)`.
From the point of view of the user, it makes sense to be able to add a grant to a principal, because that's what you do in IAM.
Right now, this
grantReadWrite()
usesidentity.addToPolicy()
identity.principal
The
addToPolicy()
call should be a no-op. Better yet, it should probably returntrue|false
on whether it did something, and if it returnsfalse
the permissions should be added on the resource instead of on the identity. This makes most use cases just work.While we're at it:
The text was updated successfully, but these errors were encountered: