Home > Software design >  Cloudformation "update your Lambda function code so that CloudFormation can attach the updated
Cloudformation "update your Lambda function code so that CloudFormation can attach the updated

Time:11-15

I am deploying the CloudFormation template from this blog post. I had to update the Lambda functions from python 3.6 to 3.9 to get it to work. Now however I get the following error message:

> CloudFormation did not receive a response from your Custom Resource.
> Please check your logs for requestId
> [029f4ea5-cd25-4593-b1ee-d805dd30463f]. If you are using the Python
> cfn-response module, you may need to update your Lambda function code
> so that CloudFormation can attach the updated version.

Below is the lambda code in question - what does it mean to update the Lambda function "so that CloudFormation can attach the updated version"?

    import util.cfnresponse
    import boto3
    import uuid
    
    client = boto3.client('s3')
    
    cfnresponse = util.cfnresponse
    
    def lambda_handler(event, context):
        response_data = {}
        try:
            if event["RequestType"] == "Create":
                bucket_name = uuid.uuid4().hex '-connect'
                # response = client.create_bucket(
                #     Bucket=bucket_name,
                # )
                response_data["BucketName"] = bucket_name
                cfnresponse.send(event, context, cfnresponse.SUCCESS, response_data)
    
            cfnresponse.send(event, context, cfnresponse.SUCCESS, response_data)
        except Exception as e:
            print(e)
            cfnresponse.send(event, context, cfnresponse.FAILED, response_data)

From what I can tell the response format follows the current version of the response module API?

CodePudding user response:

the cfnrespone lib has changed get updated. Old versions of the lib use the request lib. This CF is over 4 years old so it probably don't work due to this. You can read about the update on the last rows in the README here: https://github.com/gene1wood/cfnresponse

  • Related