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.

已提問 2 年前檢視次數 459 次
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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南