How to shut down AWS and Azure cloud instances automatically

Date Posted: 05.04.22
Read Time: 10 min

It’s the Blockbuster late fee of the DevOps world: zombie infrastructure. That’s dating myself, of course. The once-popular video rental chain expanded to more than 9,000 stores globally not on the profitability of its two-buck-a-night rentals. Rather, it amassed a sizable portion of its revenue from late fees—those pesky fines when customers failed to return their videos on time. 

For those tasked with infrastructure management on AWS or Azure (or others), the Blockbuster customer saga rings familiar. Anyone who has forgotten to shut down a sandbox that they only needed for a one-hour test has felt this pain.  

But if you’re a developer, this (common) oversight is certainly understandable. When you glance at the clock on what you believe to be Friday morning and you realize it’s Friday night, you call it a week, eager to enjoy what’s left of the weekend after 70 hours parked before your monitor. 

Let’s face it, though: Churning out applications and updates at breakneck speed is a full-time job. Surely, you can’t be expected to control costs, too. (Besides, isn’t that a job for Bob in accounting?)  

Whether you’re a developer who’s too busy to focus on cost control or someone tasked with provisioning infrastructure where costs are always top-of-mind, automation can help.  

Here we’ll explain how to shut down application environments built on AWS and Microsoft Azure cloud instances automatically, without relying on a developer or IT admin to take any action. 

Step 1. Create repeatable templates for the environments your teams need  

Part of the problem is that too many people are deploying sandbox and production environments on your cloud accounts. If each of them is responsible for also tearing those instances down, you’re relying on a lot of people complying with your policies to avoid spending too much on cloud infrastructure. Even worse—in a decentralized cloud world, you won’t know if anyone has left an instance running until you receive the cloud bill. 

Torque users alleviate this with blueprints, which are essentially repeatable templates for sandbox and production environments that include not only the cloud infrastructure but also the applications and services, configurations, dependencies, and any other resources to support an application. 

Our users then make these blueprints available via self-service and automation. For example, integrations with CI/CD tools allow engineering teams to deploy environments automatically at various stages within their pipeline. They don’t need to provision these environments repeatedly or wait on an IT admin or DevOps engineer to do it for them. 

Step 2. Set your environments (and the cloud instances behind them) to shut down automatically after custom maximum duration 

As part of your blueprint, you can set a maximum duration for the environments your teams deploy. 

For example, setting a blueprint’s maximum duration to two hours prevents any developer from deploying an environment based on that blueprint for a longer duration. After two hours, the environment is shut down automatically.

Taking it back to our earlier example with the CI/CD pipeline, this means developers can set their pipeline to deploy sandbox environments automatically at various stages of the pipeline, execute the tests they’re designed for, then shut down automatically once the test is complete. 

With custom permissions, only select Torque users can adjust the duration—thereby giving developers, testers, IT admins, and other end users access to the infrastructure they need while preventing them from spending more than they should.  

In addition to pre-set runtimes, our community also uses automation for other cloud cost optimization techniques, including: 

  • Controlling the size and types of cloud instances within blueprints, to avoid unnecessary costs from over-provisioned resources 
  • Auto-tagging cloud instances to make cost reporting easy and consistent 
  • Calculating and displaying average cost per environment so developers can understand how their cloud infrastructure affects budget 

Infrastructure automation is great, but only if it makes (dollars and) sense. And for that, you need precise control mechanisms that ensure you’re paying for what you use – and no more.  

For an up-close look on how Torque helps you shed infrastructure dollars without compromising performance, check out our video that walks you through the auto teardown and fixed run-time functionalities. 

Watch Now