aws lambda函数用于禁用和删除python boto3中的CloudFront发行版

2024-05-15 00:01:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在开发一个用python编写的Lambda函数,并使用boto3调用awsapi。
lambda函数的工作如下-

  1. 获取CloudFront分发列表。你知道吗
  2. 获取CloudFront分发ID
  3. 获取那些超过60分钟的分发的CloudFront分发配置。你知道吗
  4. 创建CloudFront分发配置的JSON文件。你知道吗
  5. 读取JSON文件并生成一个字典数组以传入cfupdateapi。你知道吗
  6. 调用updatedistributionapi并传递所需的参数。你知道吗

参考文件是-AWS Boto3

现在的问题是,只要请求的数据是正确的,updateapi就会给我一个错误。你知道吗

请找到我的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发行版。你知道吗


Tags: 文件lambda函数inparameter错误commentrequired
1条回答
网友
1楼 · 发布于 2024-05-15 00:01:18

问题是dist_list变量是调用cloudfrontclient.get_distribution_config(...)返回的值。这实际上不是分发配置。它是一个包含分发配置的字典。你知道吗

按以下方式更改更新呼叫:

dc = dist_list['DistributionConfig']
dist_update = cloudfrontclient.update_distribution(DistributionConfig=dc, ...)

相关问题 更多 >

    热门问题