Wednesday, October 26, 2022
HomeCyber SecurityRobotically Deleting a Failed CloudFormation Stack in a Rollback State | by...

Robotically Deleting a Failed CloudFormation Stack in a Rollback State | by Teri Radichel | Cloud Safety | Oct, 2022


ACM.92 Decreasing handbook actions to get issues deployed with CloudFormation

This can be a continuation of my collection on Automating Cybersecurity Metrics.

I’m simply penning this as a result of I’m uninterested in deleting stacks in a rolled again state. I don’t know why CloudFormation doesn’t do that for you or have higher choices to manage it. Right here’s what I did:

The primary command above does the next:

  • Describe the stack
  • Get the standing worth
  • Added or true (|| true) to disregard errors
  • Added 2>/dev/ null to not print out errors — — one thing I typically inform individuals to not do however on this case it is sensible.

The following command checks if the stack is in a ROLLBACK_COMPLETE state and deletes the stack whether it is. I’m presuming right here you waited to your rollback to finish earlier than making an attempt to redeploy a stack. 🙂

Now the issue is…the stack remains to be making an attempt to delete. We now have to attend till it will get right into a state the place we are able to proceed, or it may find yourself in a failure state of some type. The simplest factor to do might be wait till the stack will not be on this state: DELETE_IN_PROGRESS.

Since I now need to examine the standing a number of occasions, utilizing the principal of abstraction I’ve written about many occasions on this weblog, I moved the standing examine to it’s personal perform. I additionally realized that I wanted the /dev/null in a unique place to stop getting the error message when the stack doesn’t exist.

Then I find yourself with this code in my deploy stack perform:

That ought to save me just a little time no less than.

Now again to what I actually wish to be doing. Testing out our person’s means to log into an EC2 occasion with the important thing we created.

Observe for updates.

Teri Radichel

For those who preferred this story please clap and comply with:

Medium: Teri Radichel or E-mail Checklist: Teri Radichel
Twitter: @teriradichel or @2ndSightLab
Requests companies by way of LinkedIn: Teri Radichel or IANS Analysis

© 2nd Sight Lab 2022

All of the posts on this collection:

Github Repo

____________________________________________

Writer:

Cybersecurity for Executives within the Age of Cloud on Amazon

Want Cloud Safety Coaching? 2nd Sight Lab Cloud Safety Coaching

Is your cloud safe? Rent 2nd Sight Lab for a penetration take a look at or safety evaluation.

Have a Cybersecurity or Cloud Safety Query? Ask Teri Radichel by scheduling a name with IANS Analysis.

Cybersecurity & Cloud Safety Sources by Teri Radichel: Cybersecurity and Cloud safety courses, articles, white papers, shows, and podcasts



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments