2017-03-06 146 views
1

我想用awscli編輯/更新我的CloudFront分配。使用awscli更新cloudfront配置

我使用的是最新的CLI版本:

aws-cli/1.11.56 Python/2.7.10 Darwin/16.4.0 botocore/1.5.19

要awscli使用CloudFront的功能,你需要把它添加到您的AWS配置文件:

[preview] 
cloudfront = true 

我得到的配置我想修改的分佈:

aws cloudfront get-distribution-config --id FOO_BAR_ID > cf_config.json

看起來像按預期工作。 Config對我來說看起來不錯。現在我試圖用相同的配置重新配置我的CF發行版。

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的正確方法?

回答

1

你必須使用它與update-distribution之前編輯cf_config.json並從文件的開頭刪除

{ 
    "ETag": "ETag_Value", 
    "DistributionConfig": 

和最後

} 
從文件末尾

然後使用這個命令與從cf_config.json

aws cloudfront update-distribution --distribution-config file://cf_config.json --id FOO_BAR_ID --if-match ETag_Value 
+0

喜刪除右邊idETag價值,是有辦法做到這一切的一個bash腳本內? –