存储或检索从创建作废中的标识符

huangapple go评论53阅读模式
英文:

Store or retrieve identifier from create-invalidation

问题

我正在尝试创建一个失效请求,如下所示:

aws cloudfront create-invalidation --distribution-id  XXXXXX --paths '/*'

然后希望监听它以完成,使用以下命令:

aws cloudfront wait invalidation-completed --id <<NEED ID HERE>> --distribution-id XXXXXX && callback()

如何获取失效请求生成的ID?

英文:

I am trying to create an invalidation request as

aws cloudfront create-invalidation --distribution-id  XXXXXX --paths &#39;/*&#39;

and soon want to listen for it to complete using

aws cloudfront wait invalidation-completed --id &lt;&lt;NEED ID HERE&gt;&gt; --distribution-id XXXXXX &amp;&amp; callback()

How to get the ID generated from invalidation request?

答案1

得分: 2

将create-invalidation命令的输出存储在一个变量中

invalidation_output=$(aws cloudfront create-invalidation --distribution-id XXXXXX --paths '/*')

使用jq提取失效标识(确保您已安装jq)

invalidation_id=$(echo $invalidation_output | jq -r '.Invalidation.Id')

参考:https://docs.aws.amazon.com/cli/latest/reference/cloudfront/create-invalidation.html#examples

英文:
# Store the output of the create-invalidation command in a variable
invalidation_output=$(aws cloudfront create-invalidation --distribution-id XXXXXX --paths &#39;/*&#39;)

# Extract the Invalidation ID using jq (make sure you have jq installed)
invalidation_id=$(echo $invalidation_output | jq -r &#39;.Invalidation.Id&#39;)

Ref :https://docs.aws.amazon.com/cli/latest/reference/cloudfront/create-invalidation.html#examples

huangapple
  • 本文由 发表于 2023年7月20日 10:18:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76726271.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定