Skip to content
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(s3): supports RemovalPolicy for BucketPolicy #8158

Merged
merged 4 commits into from
May 29, 2020
Merged

feat(s3): supports RemovalPolicy for BucketPolicy #8158

merged 4 commits into from
May 29, 2020

Conversation

njlynch
Copy link
Contributor

@njlynch njlynch commented May 22, 2020

Exposes RemovalPolicy on the BucketPolicyProps so bucket policies can be
retained when a stack is deleted.

I'm conflicted about this implementation, because it seems the more recommended
way to create/associate policies with buckets is to use the addToResourcePolicy
(or the grant*) methods. One option would be to have the addToResourcePolicy
call set the removal policy on the bucket policy to whatever the policy is for
the bucket itself; however, that would be a backwards-incompatible change, and
so would need a feature flag.

Curious for feedback from the core members on this approach.

fixes #7415


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Exposes RemovalPolicy on the BucketPolicyProps so bucket policies can be
retained when a stack is deleted.

I'm conflicted about this implementation, because it seems the more recommended
way to create/associate policies with buckets is to use the addToResourcePolicy
(or the grant*) methods. One option would be to have the addToResourcePolicy
call set the removal policy on the bucket policy to whatever the policy is for
the bucket itself; however, that would be a backwards-incompatible change, and
so would need a feature flag.

Curious for feedback from the core members on this approach.

fixes #7415
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 978cccc
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@iliapolo
Copy link
Contributor

@njlynch you mentioned:

One option would be to have the addToResourcePolicy
call set the removal policy on the bucket policy to whatever the policy is for
the bucket itself; however, that would be a backwards-incompatible change

Yeah, I wouldn't go down that road...

Since the Bucket construct exposes its policy using the policy attribute, I suggest adding an API to the BucketPolicy ti support configuring it:

const bucket = new s3.Bucket(this, 'Bucket', {});
bucket.policy?.setRemovalPolicy(RemovalPolicy.DELETE);

WDYT?

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: f9b8573
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 9a8801a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@njlynch njlynch marked this pull request as ready for review May 27, 2020 10:53
@mergify
Copy link
Contributor

mergify bot commented May 29, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 43e0160
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented May 29, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit cb71f34 into aws:master May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

s3: Better way to set BucketPolicy deletion policy
3 participants