简体   繁体   中英

AWS Codepipeline Deploy to S3 with a --delete flag

AWS Codepipeline supports deploying to S3 .

I have an Angular SPA that I'm deploying to S3 as a static website (using Cloudfront, etc)

When I do the ng build --prod command, I include outputHashing , which will change the file names deployed over time.

However when deploying to S3 in my Codepipeline, it's not removing old js/css files with different hashes, but continually adding new files

I'd like to use Codepipeline to deploy to S3 with the same behavior as

aws s3 sync ./dist s3://mywebsite-bucket.com/ --acl public-read --delete

Note the --delete flag.

Is this possible to set up in Codepipeline when deploying to S3?

I use a similar set-up, as s3 deployment with --delete is currently not possible . Instead, see bash commands below, use a codebuild stage for deployment in the codepipeline.

echo "Syncing directory files to s3"
aws s3 sync ./dist s3://mywebsite-bucket.com/ \
--grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers \
--delete

Note, grants command will achieve same outcome as --acl public-read.

Does this have any update now??

I use code pipeline(CodeCommit --> CodeBuild --> CodeDeploy:s3) to build a static website. But while deploying in s3 the build files keep piling up on every run of the pipeline.

Is there a way to delete and replace the previous build files on the next deployment?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM