-
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): customize IAM role creation behavior #22856
Conversation
Introduces a new static method `Role.customizeRoles` which allows customization of role creation behavior. By default this will prevent all IAM roles and policies from being created (they will not be synthesized in the template) and will generate a policy report (both human and machine readable versions) in the cloud assembly (i.e. cdk.out) with information on the roles that need to be created and their associated IAM policies. If `customizeRoles.preventSynthesis=true` then this will - prevent IAM roles (AWS::IAM::Role) from being created - prevent managed policies (AWS::IAM::ManagedPolicy) from being created - prevent IAM policies (AWS::IAM::Policy) from being created - Managed policies that are created and _not_ attached to a role will not be synthesized _and_ will not be added to the report. Errors are added using `Annotations.addError` so that the app will still synthesize to the `cdk.out` directory and the policy report will be generated. The policy report can be generated _without_ preventing resource synthesis by setting `customizeRoles.preventSynthesis=false`. I added an integration test `aws-lambda/test/integ.lambda-customize-roles.ts` that will only synthesize the snapshot. You can view the generated reports in the snapshot. refactored: - Moved the `Import` class that was created under the `fromRoleArn` to a separate private class (imported-role.ts). The implementation is the same (just moved). closes #22749
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). |
Introduces a new static method
Role.customizeRoles
which allows customization of role creation behavior. By default this will prevent all IAM roles and policies from being created (they will not be synthesized in the template) and will generate a policy report (both human and machine readable versions) in thecloud assembly (i.e. cdk.out) with information on the roles that need to be created and their associated IAM policies.
If
customizeRoles.preventSynthesis=true
then this willErrors are added using
Annotations.addError
so that the app will still synthesize to thecdk.out
directory and the policy report will be generated.The policy report can be generated without preventing resource synthesis by setting
customizeRoles.preventSynthesis=false
.I added an integration test
aws-lambda/test/integ.lambda-customize-roles.ts
that will only synthesize the snapshot. You can view the generated reports in the snapshot.refactored:
Import
class that was created under thefromRoleArn
to a separate private class (imported-role.ts). The implementation is the same (just moved).This also adds support for the role created as part of custom resources in
core
.closes #22749, closes #22862
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