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?