Force CloudFront distribution/file update

后端 未结 13 1248
失恋的感觉
失恋的感觉 2020-12-07 07:01

I\'m using Amazon\'s CloudFront to serve static files of my web apps.

Is there no way to tell a cloudfront distribution that it needs to refresh it\'s file or point

13条回答
  •  长情又很酷
    2020-12-07 07:54

    current AWS CLI support invalidation in preview mode. Run the following in your console once:

    aws configure set preview.cloudfront true
    

    I deploy my web project using npm. I have the following scripts in my package.json:

    {
        "build.prod": "ng build --prod --aot",
        "aws.deploy": "aws s3 sync dist/ s3://www.mywebsite.com --delete --region us-east-1",
        "aws.invalidate": "aws cloudfront create-invalidation --distribution-id [MY_DISTRIBUTION_ID] --paths /",
        "deploy": "npm run build.prod && npm run aws.deploy && npm run aws.invalidate"
    }
    

    Having the scripts above in place you can deploy your site with:

    npm run deploy
    

提交回复
热议问题