Why does my stack deletion fail because of an error that occurs when deleting a custom resource?

0

My custom resource is configured as follows:

Resources:
    SecretTagValCreation:
      Type: Custom::SecretTagValCreation
      Properties:
        ServiceToken: arn:aws:lambda:us-east-2:ACCOUNT_NUMBER:function:ReturnSecretToCFNForEC2
        Region: !Ref "AWS::Region"
        Env: !Ref 'EnvTagValue'
        ProjID: !Ref 'ProjIDTagValue'
        Dept: !Ref 'DepTagValue'
        Owner: !Ref 'OwnerTagValue'
        StackID: !Ref 'AWS::StackId'
        StackName: !Ref 'AWS::StackName'

I have the AWS CloudFormation stack created in one account, and an AWS Lambda function created in a different account. My code works, and the Lambda function can be invoked by the CloudFormation role. However, I can't delete my stacks because the custom resource doesn't get deleted during stack creation. The status of the stack is "DELETE_FAILED" or "ROLLBACK_FAILED" (if there is an error with stack). If I retain the custom resource and try deleting the stack again, then the stack gets deleted. However, this is not ideal. How do I delete the resources properly?

asked 3 years ago691 views
1 Answer
0
Accepted Answer

This issue occurs under one or more of the following conditions:

  • You don't send a response.
  • An issue occurs during your handler's cleanup.

Check if you've implemented the delete event in your Custom Resource (event['RequestType'] == 'Delete').

AWS
EXPERT
Raphael
answered 3 years ago
AWS
EXPERT
reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions