nideveloper / CDK-SPA-Deploy

This is an AWS CDK Construct to make deploying a single page website (Angular/React/Vue) to AWS S3 behind SSL/Cloudfront easier
MIT License
235 stars 40 forks source link

Feature Request: Add support for autoDeleteObjects and removalPolicy properties on created Bucket #306

Open El-Jefe-Carne opened 3 years ago

El-Jefe-Carne commented 3 years ago

Recently found and used this package in an implementation. Fantastic work, and really appreciate what has been done here.

I ran destroy for the first time on my stack and I noticed that cloud formation had its bucket deletion skipped. Since this package uses the Bucket object from @aws-cdk/aws-s3 package, I was hoping you could add support into this project's config that allows me to set the removalPolicy and autoDeleteObjects from the SPADeploy config object.

In attempting to do this without an update to the pacakage, I added the following to my code after the initialization of the SPADeploy:

deployment.websiteBucket.applyRemovalPolicy(RemovalPolicy.DESTROY);

Unfortunately, CloudFormation won't delete a bucket with objects in it unless the autoDeleteObjects prop is set to true in the Bucket config, and I don't see a way to set that after initialization of the Bucket like with the removalPolicy.

Looking for this: image

Thanks again!

SimonLdj commented 3 years ago

Hi @El-Jefe-Carne , just noted my PR https://github.com/nideveloper/CDK-SPA-Deploy/pull/362 match exactly for what you are asking for. Basically waiting for the owner to take a look :)