aws_cdk.s3: IAM policy created despite using notifications_handler_role
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
When creating an instance of s3.Bucket, I use notifications_handler_role to explicitly choose an IAM role to be used for the Lambda function that will create the bucket notifications. Despite that, CDK generates an IAM policy and attaches it to the role that I provided. For example:
` HandlerRolePolicy39F50E2E:
Type: AWS::IAM::Policy
Properties:
PolicyDocument:
Statement:
- Action: s3:PutBucketNotification
Effect: Allow
Resource: "*"
Version: "2012-10-17"
PolicyName: HandlerRolePolicy39F50E2E
Roles:
- s3_handler_role
Metadata:
aws:cdk:path: AspectsStack/HandlerRole/Policy/Resource`
I do NOT want a policy created. I will add the correct policies to the role as needed.
### Use Case
I work in an environment where I do not have permission to create IAM roles or policies. Those are created by a central admin team. I need CDK to NOT create any roles or policies.
### Proposed Solution
In the implementation of notifications_handler_role, do not create a new policy.
### Other Information
_No response_
### Acknowledgements
- [x] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
2.27.0 (build 8e89048)
### Environment details (OS name and version, etc.)
AWS Cloud9
Contributor guide
Research direction
Start by locating the s3.Bucket implementation of notifications_handler_role and any related tests. Reproduce the issue with a supplied handler role and inspect the synthesized AWS template; done means no IAM policy is created or attached to that role while bucket notifications still work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100