-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat: grants are now available through a separate class #35782
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
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.
(This review is outdated)
| { | ||
| "resources": { | ||
| "Topic": { | ||
| "targetField": "arn", |
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.
Is this what's going in the resourceArns in the call to Grant.addToPrincipalOrResource?
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.
That's what I was thinking yes
… huijbers-otaviom/grants
This reverts commit 49d3863.
# Conflicts: # tools/@aws-cdk/spec2cdk/lib/cdk/resource-class.ts # tools/@aws-cdk/spec2cdk/lib/cdk/resource-decider.ts
f1e9873 to
1cb6f2d
Compare
# Conflicts: # packages/aws-cdk-lib/aws-route53/lib/hosted-zone.ts # packages/aws-cdk-lib/aws-route53/lib/util.ts
# Conflicts: # tools/@aws-cdk/spec2cdk/lib/cdk/ast.ts # tools/@aws-cdk/spec2cdk/lib/cdk/resource-class.ts # tools/@aws-cdk/spec2cdk/lib/cfn2ts/index.ts # tools/@aws-cdk/spec2cdk/lib/generate.ts
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
|
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). |
|
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). |
|
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). |
|
Comments on closed issues and PRs are hard for our team to see. |
Instead of grants being attached to the L2 class, they are now available as separate classes.
For example, for
Topicthe grants are now available as theTopicGrantsclass. This class is exposed as a public member:public readonly grants: TopicGrants, and can be used like this:The
grantPublishetc methods on the L2 are now no longer recommended (though they will not be deprecated immediately to not disrupt existing code too much). Instead, all examples now use the new methods, and a linter will prevent newgrantXxx()methods from being added to the L2 level. Instead, Grant classes should be written.The grants class can also be used if you have an L1, and can be generated for services that don't have L2s yet.
They are currently driven from a datafile,
grants.json, in the service module directory. This data source may move to theawscdk-service-specrepo in the future.Example
An example of a generated grants class, for SNS topics:
A few things to note:
_from<Resource>(). For now, while we experiment with this idea, this method is marked as internal, hence the_leading the name.keyActions, the generated class will also have anencryptedResourceproperty, that allows the Grants class to add permissions to the key, if it's present. This is done via theIEncryptedResourceinterface.hasPolicy: true, the generated class will also have apolicyResourceproperty, that allows the Grants class to create a resource policy.Also in this PR
spec2cdk, and a slight attempt at making it more obvious thatspec2cdkhas 2 distinct entry points; no attempt at reconciling these 2 entry points yet, I fear that's going to be a time suck.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license