Power down environments with one command
Web applications are typically organized and hosted via environments that are replicated for different purposes. The “production” environment is for the live site, “staging” for the almost-live product, “testing” and “dev” environments for code that is still being cooked.
Each environment consists of many cloud resources: servers, containers, load balancers, databases and caches that combine to provide the service.
The problem is: How do you control a complete environment with a single command to power it up or down?
Infrastructure as code
It is best if these environments are as similar as possible so that production issues are caught in dev, test or staging before going live to production. Using a tool like Terraform, you can define these environments as “code” and easily replicate them. This is called “Infrastructure as Code” and has other benefits including improved security.
Terraform is ideal for creating and destroying environments and you can be confident that a “test” environment will faithfully simulate the “production” environment. With Terraform you can easily scale up or down configurations for different environments. For example: “test” does not need to have as many instances as “production”. However, Terraform is not the best at starting and stopping environments.
Idle resources are costly
AWS and other cloud providers charge by the second for any resources that are active in your account. So those “test” and “staging” environments can be quite wasteful when they are not being used.
These environments are typically not required 24x7 and some may be only required during certain business hours. By simply powering down these resources, you can realize savings of up to 70% of their cloud bill. So, how to stop such environments and quickly restart?
Use Terraform to stop the environment?
Terraform is good at creating and destroying environments, but doing a full destroy and re-create is slow and not the best approach, especially if the resources can be simply stopped and then restarted as needed. Creating and destroying is also much more complex and error prone than simply starting and stopping resources.
AWS fast start, quick stop
Many AWS resources can be started and stopped very quickly. AWS On-Demand and Spot instances, AutoScale groups, RDS databases and ECS Fargate containers can be stopped and started in under a minute — often within seconds. You can use the AWS console, CLI or API to start and stop resources.
However, Amazon does not provide a simple way to organize a group of resources into an environment and to power up as a group. Nor does it provide a way to manage inter-resource dependencies. For this we need a different tool.
PowerDown Cloud Optimizer
The PowerDown cloud optimizer is designed to manage the availability of resource environments. While it can easily turn on and off individual resources, it can also group collections of resources into a complete environment and then power them up and down with a single click. Resource groups can also be scheduled to meet any users availability needs via a dynamic schedule.
PowerDown Resource Groups
Using PowerDown, you represent your environments as PowerDown resource groups. PowerDown resource groups are an ordered collection of cloud resources and other resource groups that can be managed as a unit. You can create a resource group to represent each of your environments.
Resource groups form a tree of resources of any depth. If the top group, in this case “Testing”, is powered up or down, PowerDown will orchestrate the powering of all sub-resources in sequence.
Resources may be shared by multiple resource groups and users may have overlapping (or contradictory) requests for resources to be available. PowerDown resolves these competing demands and ensures that any resource that is required by any user, will be available as required. It optimizes the requests to ensure the maximum savings by powering down all eligible resources.