- Newest
- Most votes
- Most comments
Is this a concrete use case or just an example to test Custom Resources? If this is a concrete use case, can you explain why do you need to create a directory in the bucket? With Amazon S3 folders are just determined implicitly from the keys of the objects you store. If you store an object with key alfa/beta/gamma.txt
in an empty bucket when browsing the S3 bucket you will see alfa
and beta
represented as folders.
Regarding your question, the Cloud Formation stack might get stuck because your customer resource lambda code contains an error and does not return the proper failure message to CloudFormation (see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-lambda-function-code-cfnresponsemodule.html)
BTW writing custom resources in Python is made much easier by using https://github.com/aws-cloudformation/custom-resource-helper. See also https://aws.amazon.com/blogs/infrastructure-and-automation/aws-cloudformation-custom-resource-creation-with-python-aws-lambda-and-crhelper/.
Relevant content
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated 2 years ago
We need the directory/folder inside the s3 bucket. Is there a way to make cloudformation return the error, reason its doing what is suppose to do, creating the directory.
You need to catch possible errors in the lambda function and return a FAILED status. The
cfnresponse
module does not allow to specify the value of the Reason field, which is defined by the library itself. See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-lambda-function-code-cfnresponsemodule.html#w2ab1c23c23c16b9c15Not sure why - we need to add empty dictionary in python string response_data = {} and send in response. cfnresponse.send(event, context, cfnresponse.SUCCESS, response_data)
Hi.
As MassimilianoAWS says, first you need to set cfnresponse for error handling.
And check the execution log of the Lambda function you created for your custom resource to see why the error is occurring.
You may be able to get detailed information about the error.
For example, if the Lambda execution role does not have permission to the target bucket.