简体   繁体   English

为什么aws cli不会使缓存无效 - AWS Cloudfront

[英]Why aws cli dont invalidate correctly the cache - AWS Cloudfront

I have created a Jenkins job that invalidate the cache each time that my frontend project is deployed. 我创建了一个Jenkins作业,每次部署我的前端项目时都会使缓存失效。 The issue is that although the AWS Website display that the cache is invalidating, when the job finish, the cache isnt completly cleaned, so I need to invalidate it manually through the AWS Website... 问题是虽然AWS网站显示缓存无效,但是当作业完成时,缓存不会完全清理,因此我需要通过AWS网站手动使其无效...

The way to invalidate the cache automatically that I used is through aws container where I execute the following command: 我使用的自动缓存无效的方法是通过aws容器执行以下命令:

  • aws cloudfront create-invalidation --distribution-id ${DISTRIBUTION_ID} --paths /* > output.json

The output file will contain a json where I can get differents keys: values. 输出文件将包含一个json,我可以在其中获取不同的键:值。 Two of they that I use is Id and Status . 我使用的两个是IdStatus Once the invalidation was created, I another pipeline step I execute the following: 创建失效后,我执行另一个管道步骤:

  • aws cloudfront get-invalidation --distribution-id ${DISTRIBUTION_ID} --id ${id_invalidator} > status_invalidation.json

With the previously command I quest to the API each 50 second (through a sleep 50 ) the status of the invalidation. 使用先前的命令,我每隔50秒(通过sleep 50 )查询API失效的状态。 When the validation return a `Status = Completed', the job is finished. 当验证返回“Status = Completed”时,作业结束。 This condition are inside a while loop. 这个条件在while循环中。

Someone know why this is happened? 有人知道为什么会这样吗?

You always have to quote expressions with the * character on the command line, to avoid local shell expansion. 您始终必须在命令行上使用*字符引用表达式,以避免本地shell扩展。 The correct syntax is this: 正确的语法是这样的:

--paths '/*'

Otherwise you are trying to invalidate names based on what's in the root directory on your local filesystem (as captured by the * , expanded by the shell). 否则,您将尝试根据本地文件系统上的根目录中的内容使名称无效(由*捕获,由shell扩展)。

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

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