使用awscli更新Cloudfront配置 [英] Update cloudfront configuration using awscli
问题描述
我想使用awscli编辑/更新我的CloudFront发行版.
I would like to edit/update my CloudFront distribution with awscli.
我正在使用最新的cli版本:
I'm using latest cli version:
aws-cli/1.11.56 Python/2.7.10 Darwin/16.4.0 botocore/1.5.19
要在awscli中使用cloudfront功能,需要将其添加到aws配置文件中:
To use cloudfront features in awscli you need to add this to your aws config file:
[preview]
cloudfront = true
我正在配置要修改的发行版:
I'm getting config of the distribution that I'd like to modify:
aws cloudfront get-distribution-config --id FOO_BAR_ID>cf_config.json
看起来像预期的那样工作.配置对我来说还可以.现在,我尝试使用相同的配置重新配置CF发行版.
Looks like it worked as expected. Config looks ok for me. Now I'm trying to reconfigure my CF distribution with the same config.
aws cloudfront update-distribution --distribution-config file://cf_config.json --id FOO_BAR_ID
我得到:
Parameter validation failed:
Missing required parameter in DistributionConfig: "CallerReference"
Missing required parameter in DistributionConfig: "Origins"
Missing required parameter in DistributionConfig: "DefaultCacheBehavior"
Missing required parameter in DistributionConfig: "Comment"
Missing required parameter in DistributionConfig: "Enabled"
Unknown parameter in DistributionConfig: "ETag", must be one of: CallerReference, Aliases, DefaultRootObject, Origins, DefaultCacheBehavior, CacheBehaviors, CustomErrorResponses, Comment, Logging, PriceClass, Enabled, ViewerCertificate, Restrictions, WebACLId, HttpVersion, IsIPV6Enabled
Unknown parameter in DistributionConfig: "DistributionConfig", must be one of: CallerReference, Aliases, DefaultRootObject, Origins, DefaultCacheBehavior, CacheBehaviors, CustomErrorResponses, Comment, Logging, PriceClass, Enabled, ViewerCertificate, Restrictions, WebACLId, HttpVersion, IsIPV6Enabled
使用awscli重新配置CF的正确方法是什么?
What is the right way to reconfigure CF using awscli?
推荐答案
您必须先将cf_config.json与 update-distribution
结合使用并删除
You have to edit cf_config.json before using it with update-distribution
and remove
{
"ETag": "ETag_Value",
"DistributionConfig":
从文件开头到最后
}
从文件末尾开始.
然后将此命令与正确的 id
和 ETag
值一起使用,该值已从 cf_config.json
Then use this command with the right id
and ETag
value that was removed from cf_config.json
aws cloudfront update-distribution --distribution-config file://cf_config.json --id FOO_BAR_ID --if-match ETag_Value
这篇关于使用awscli更新Cloudfront配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!