wesupport

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Delete an AWS CloudFormation stack with ease

by | Nov 15, 2021

Delete an AWS CloudFormation stack stuck in DELETE_FAILED status without a second thought. Bobcares is here to answer your whys and hows.

At Bobcares, we often get similar queries as a part of our AWS Support Service.

Why can’t I delete an AWS CloudFormation stack?

Deleting your stack when it is stuck in the DELETE_FAILED can prove to be challenging. However, our Support Techs have found a way to get this done. Before we delve into the different ways to resolve the issue, let’s take a look at the reasons behind the DELETE_FAILED status:

  • The stack resource may have a dependent object or further dependencies that can not be deleted. This can be resolved by the steps in Section 1 of this article.
  • The security token within the delete request may be invalid. In some cases, the role may be invalid or cannot be assumed. This can be resolved by the steps in Section 2.
  • The custom resource may have failed to stabilize within the expected amount of time. We can resolve this issue by following the steps mentioned in Section 3.

Section 1: How to delete an AWS CloudFormation stack

Dependency issue often occurs when an out-of-band change is made. For instance, in case the stack fails due to a security group that is a part of your stack is actually attached to an ENI that is not a part of your stack.

The stack will ultimately fail since the security group resource cannot be deleted. In order to delete the stack in this example, you will to retain the dependent resource.

  1. First, open the AWS CloudFormation console.
  2. Then, select the stack stuck in the DELETE_FAILED status.
  3. After that, choose Delete. You will see a window that lists out the resources that have failed to delete.
  4. Next, select the resource you prefer to retain and then finally select Delete stack.

These steps ensure that none of the resources you want to be retained will be deleted when you attempt to delete the stack. Moreover, this will change the status of your stack to DELETE_COMPLETE.

Additionally, our Support Techs recommend manually deleting the retained resources when the stack is deleted to avoid unnecessary changes.

Section 2: How to delete an AWS CloudFormation stack

In this scenario, you will receive an error message along the lines:
“An error occurred (ValidationError) when calling the DeleteStack operation: Role is invalid or cannot be assumed.” You can resolve this error with these steps:

  1. First, open the AWS CloudFormation console.
  2. Next, select the stack with the DELETE_FAILED status.
  3. After that, take a look at the Stack Info tab and note the IAM role name assigned to the stack.
  4. Then, create a new IAM role using the same name that you noted in the previous step.
  5. Now, go to the AWS CloudFormation console and delete the stack stuck in the DELETE_FAILED status.

Once you complete these steps, you will notice the stack status has changed to DELETE_COMPLETE.

Section 3: How to delete an AWS CloudFormation stack

If you come across “Custom Resource failed to stabilize in expected time.” error message when trying to delete a stack, these steps will come in handy:

  1. First, open the AWS CloudFormation console.
  2. Then, select the stack with the DELETE_FAILED status and custom resource.
  3. After that, select Actions and choose Delete Stack.
  4. Next, you will come across a pop-up window with the list of resources to retain. Select the custom resource and select Delete.
  5. Then, select Actions and Delete Stack.

Our Support Techs would like to remind you that since the custom resource is not a physical resource you don’t have to worry about cleaning it up after stack deletion.

[Facing trouble with Server Management? We are just a click away.]

Conclusion

At the end of the day, we learned how to delete a stack stuck in the DELETE_FAILED status based on the reason behind the status. The skilled Support Techs at Bobcares demonstrated three different ways to change the stack status to DELETE_COMPLETE.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags