aws-cdk
aws-cdk copied to clipboard
feat(aws-s3): allow customising role used for autoDeleteObjects
It's currently not possible to use autoDeleteObjects in a restricted environment where role creation is not allowed because it always creates a new role for the underlying lambda-backed custom resource provider.
This change introduces a new property autoDeleteObjectsRole allowing a user-provided role to be used instead of creating a new one. The custom resource provider will still act as a singleton but for a specific role instead i.e. at most one custom resource provider is created for every unique instance of autoDeleteObjectsRole.
This hopefully brings things in line with other custom-resource backed constructs/features, e.g. BucketDeployment or S3 bucket notifications where the role used for the underlying custom resource provider can be manually specified.
Fixes #16496
All Submissions:
- [x] Have you followed the guidelines in our Contributing guide?
Adding new Unconventional Dependencies:
- [ ] This PR adds new unconventional dependencies following the process described here
New Features
- [x] Have you added the new feature to an integration test?
- [x] Did you use
yarn integto deploy the infrastructure and generate the snapshot (i.e.yarn integwithout--dry-run)?
- [x] Did you use
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
Thanks for the comment @TheRealAmazonKendra - that's a really good point. I tested this and actually it turns out updating custom resources with a new service token isn't supported by CloudFormation, so the stack deploy fails against an existing stack. Oops.
So that means I'll have to create a new custom resource instead (which would drop the old one when updating a stack) pointing to the new lambda provider. This approach is also a bit problematic as the old custom resource will attempt to empty the bucket when deleted as a side effect, not ideal.
I'll have to dig into this a bit more, it looks like an issue similar to https://github.com/aws/aws-cdk/issues/7128 so maybe there's some wisdom I can borrow from the fix applied there. I'll convert it to a draft PR in the mean time until I have a more concrete solution.
This PR has been in the MERGE CONFLICTS state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.
AWS CodeBuild CI Report
- CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
- Commit ID: a4249b36e0775bda3d2b4d0ba6fed708b6d0434b
- Result: FAILED
- Build Logs (available for 30 days)
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository
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.
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.
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.
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.
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.
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.
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 has been in the BUILD FAILING state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.
This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error.