【发布时间】:2020-04-07 00:24:32
【问题描述】:
我正在开发一个用 python 编写并使用 boto3 调用 AWS API 的 Lambda 函数。
lambda函数的工作如下-
- 获取 CloudFront 分配列表。
- 获取 CloudFront 分配 ID。
- 获取超过 60 分钟的分发的 CloudFront 分发配置。
- 创建 CloudFront 分配配置的 JSON 文件。
- 读取 JSON 文件并制作字典数组以传入 CF 更新 API。
- 调用更新分发 API 并传递所需参数。
参考文档是-AWS Boto3
现在的问题是,只要请求的数据正确,更新 API 就会给我一个错误。
请找到我的 python lambda 函数代码链接 - Lambda function to disable and delete CloudFront destribution
这是我在通过更新 API 更新(禁用)CloudFront 分发时遇到的错误-
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, OriginGroups, 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, OriginGroups, DefaultCacheBehavior, CacheBehaviors, CustomErrorResponses, Comment, Logging, PriceClass, Enabled, ViewerCertificate, Restrictions, WebACLId, HttpVersion, IsIPV6Enabled
Unknown parameter in DistributionConfig: "ResponseMetadata", must be one of: CallerReference, Aliases, DefaultRootObject, Origins, OriginGroups, DefaultCacheBehavior, CacheBehaviors, CustomErrorResponses, Comment, Logging, PriceClass, Enabled, ViewerCertificate, Restrictions, WebACLId, HttpVersion, IsIPV6Enabled
上面的错误信息显示参数丢失,但我检查了请求是否包含所有必需的参数,我不明白为什么它给出错误。
如果有人对此有任何解决方案,请分享或任何其他想法以从 AWS Lambda 禁用和删除 CloudFront 分发。
【问题讨论】:
-
试试
update_distribution(DistributionConfig=dist_list['DistributionConfig'], ...)
标签: python amazon-web-services aws-lambda boto3 amazon-cloudfront