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

aws lambda函数,用于禁用和删除python boto3中的CloudFront发行版,python,amazon-web-services,aws-lambda,boto3,amazon-cloudfront,Python,Amazon Web Services,Aws Lambda,Boto3,Amazon Cloudfront,我正在开发一个用python编写的Lambda函数,并使用boto3调用AWSAPI。 lambda函数的工作如下- 获取CloudFront分发列表 获取CloudFront分发ID 获取那些超过60分钟的发行版的CloudFront发行版配置 创建CloudFront分发配置的JSON文件 读取JSON文件并制作一个字典数组以传入CF update API 调用更新分发API并传递所需的参数 参考文件是— 现在的问题是,只要请求的数据是正确的,更新API就会给我一个错误 请找到我的pytho

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

  • 获取CloudFront分发列表
  • 获取CloudFront分发ID
  • 获取那些超过60分钟的发行版的CloudFront发行版配置
  • 创建CloudFront分发配置的JSON文件
  • 读取JSON文件并制作一个字典数组以传入CF update API
  • 调用更新分发API并传递所需的参数
  • 参考文件是—

    现在的问题是,只要请求的数据是正确的,更新API就会给我一个错误

    请找到我的python lambda函数代码链接-

    下面是我在通过更新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分发版的任何其他想法。

    问题在于,您的
    dist\u list
    变量是调用
    cloudfrontclient.get\u distribution\u config(…)
    返回的值。这实际上不是分发配置。它是一个包含分发配置的字典

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

    dc = dist_list['DistributionConfig']
    dist_update = cloudfrontclient.update_distribution(DistributionConfig=dc, ...)
    
    请尝试更新分发(DistributionConfig=dist\u列表['DistributionConfig'],…)