Is there a way to conditionally trigger the delete API on custom resources formed using the cloudformation template?

0

Hi. My use case requires that I'll be onboarding an AWS account onto my platform and for that I'll be creating some aws as well as custom resources. These custom resources will be calling my lambda function which will point to the respective add API in backend. After successful onboarding, if I onboard that same account again, the backend checks should throw an error that says account is already onboarded and this will trigger the delete api automatically in the rollback process. What if, through my cloudformation template I want to stop the delete API call just in this case as a conditional requirement? Or is there a way to do it by changing the execution of my lambda functions? If there are any examples or solutions that you can point me to it'd be of a great help. Thanks.

1개 답변
0

The DELETE operation will be invoked only for resources that have been created. Add a check in your lambda function to verify if the account has already been on-boarded and return a FAILED status in such case. This causes the stack creation to fail and triggers the rollback of anything that has been created. By putting the custom resource that does the check as dependency of all the other resources in the stack, you avoid the creation of any further resource unless the custom resource succeeds.

AWS
전문가
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠