I am working on a Lambda Function written in python and using boto3 to call AWS APIs.
Work of lambda function as follows -
- Get the CloudFront Distribution list.
- Get the CloudFront Distribution ID.
- Get the CloudFront Distribution Config of those distribution which older than 60 minutes.
- Create a JSON file of CloudFront Distribution Config.
- Read the JSON file and make a dictionary array to pass in CF update API.
- Call Update Distribution API and pass the required parameters.
Reference Document is - AWS Boto3
Now the problem is, the update API giving an error to me as far as the requested data is correct.
Please find my python lambda function code link - Lambda function to disable and delete CloudFront destribution
Here is the error I am getting while updating (disable) CloudFront distribution via update API-
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
The above error message shown the parameters are missing but I have checked the request has all the required parameters, I didn't understand why its giving error.
If someone has any solution for this please share or any other idea to disable and delete CloudFront distribution from AWS Lambda.
update_distribution(DistributionConfig=dist_list['DistributionConfig'], ...)
– jarmod