简体   繁体   English

AWS Codepipeline 使用 --delete 标志部署到 S3

[英]AWS Codepipeline Deploy to S3 with a --delete flag

AWS Codepipeline supports deploying to S3 . AWS Codepipeline 支持部署到 S3

I have an Angular SPA that I'm deploying to S3 as a static website (using Cloudfront, etc)我有一个 Angular SPA,我将其作为 static 网站(使用 Cloudfront 等)部署到 S3

When I do the ng build --prod command, I include outputHashing , which will change the file names deployed over time.当我执行ng build --prod命令时,我包含outputHashing ,它将随着时间的推移更改部署的文件名。

However when deploying to S3 in my Codepipeline, it's not removing old js/css files with different hashes, but continually adding new files但是,在我的 Codepipeline 中部署到 S3 时,它不会删除具有不同哈希值的js/css 文件,而是不断添加新文件

I'd like to use Codepipeline to deploy to S3 with the same behavior as我想使用 Codepipeline 以相同的行为部署到 S3

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

Note the --delete flag.注意--delete标志。

Is this possible to set up in Codepipeline when deploying to S3?部署到 S3 时是否可以在 Codepipeline 中进行设置?

I use a similar set-up, as s3 deployment with --delete is currently not possible .我使用了类似的设置,因为目前无法使用 --delete 进行 s3 部署。 Instead, see bash commands below, use a codebuild stage for deployment in the codepipeline.相反,请参阅下面的 bash 命令,使用代码构建阶段在代码管道中进行部署。

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.请注意,grants 命令将获得与 --acl public-read 相同的结果。

Does this have any update now??这个现在有更新吗??

I use code pipeline(CodeCommit --> CodeBuild --> CodeDeploy:s3) to build a static website.我使用代码管道(CodeCommit --> CodeBuild --> CodeDeploy:s3)来构建一个 static 网站。 But while deploying in s3 the build files keep piling up on every run of the pipeline.但是在 s3 中部署时,构建文件会不断堆积在管道的每次运行中。

Is there a way to delete and replace the previous build files on the next deployment?有没有办法在下次部署时删除和替换以前的构建文件?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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