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?

preguntada hace 3 años698 visualizaciones
1 Respuesta
0
Respuesta aceptada

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
EXPERTO
Raphael
respondido hace 3 años
AWS
EXPERTO
revisado hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas