Skip to content

A serverless application which removes CloudFormation stacks based on configurable parameters as part of AWS environment automation

License

Notifications You must be signed in to change notification settings

pariveda-serverless/odin

 
 

Repository files navigation

Build statusKnown VulnerabilitiesDependency StatusdevDependency StatusLicenseCode style

Odin

Odin, or Wōtan, is a Norse god who directs the valkyries and is the guardian of Valhalla. Half of those who perish in combat are welcomed by him into his majestic halls where they prepare for the final battle against Fenrir during the events of Ragnarök.

What it does

This serverless application periodically checks the status of CloudFormation stacks in your AWS environment and sends the stale ones to Valhalla.

Odin currently determines that a stack is stale and should be removed when it doesn't fit any of the following three criteria:

  1. Tagging: If a stack is tagged with the stage 'Production' or 'Automation' (or either's derivatives, like 'Prod' or 'Auto') then it is ineligible for deletion
  2. Status: If a stack's status is in a failure or in-progress state then it is ineligible for deletion
  3. Age: If a stack has been updated recently then it is ineligible for deletion

If a stack doesn't match one of the above criteria then it is removed.

How to use it

Odin is built with the Serverless Framework - see their documentation for more about the tool and how to use it.

To change the frequency with which Odin runs and the settings used to determine whether a stack is eligible for deletion modify the values in odin.yml and redeploy the application.

Limitations

Unlike his Norse namesake Odin is unable to practice magic and cannot remove stacks that aren't self-removing.

A common example of this situation is a stack which creates an S3 bucket that is later filled with files. If the stack doesn't contain the resources necessary to empty and then delete this bucket any stack delete commands (whether triggered by Odin, manually, or any other means) will end with the stack in an error state. Don't treat your stacks this way - let them enter Valhalla with honor!

For this specific scenario you can use a tool like the empty-s3-bucket service found in Lambda Utilities in combination with a custom CloudFormation resource to empty buckets when a stack is deleted. See the infrastructure section of Santa Swap UI for a real-world example of how this can be achieved within a stack.

Another approach is to let Odin empty your S3 buckets for you prior to calling the delete stack command. This approach requires you to output the bucket name in your CloudFormation stack, and then add the output key name to odin.yml. By default Odin will empty the deployment buckets created by the Serverless Framework.

Architecture overview

odin - architecture overview

Odin image source

Murray, Alexander (1874). Manual of Mythology : Greek and Roman, Norse, and Old German, Hindoo and Egyptian Mythology. London, Asher and Co. This illustration is from plate XXXV. Digitized version of the book by the Internet Archive, https://archive.org/details/manualofmytholog00murruoft Published earlier in Reusch, Rudolf Friedrich. 1865. Die nordischen Göttersagen.

About

A serverless application which removes CloudFormation stacks based on configurable parameters as part of AWS environment automation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 91.1%
  • JavaScript 8.9%