Schedule Stopping of AWS EC2 Instances

Updated 1 week ago by Totalcloud

Starting and stopping of AWS EC2 instances, when not in use, leads to an enormous amount of cost savings.

There's a template already available in the web app for this use case. This workflow template helps you automate stopping of EC2 instances belonging to development environment every Friday 9pm.

Please find below the information on how this template works and how you can customize it according to your needs.

How Does This Template Work?

  1. Trigger node initiates the workflow every Friday at 9pm.
  2. Resource node fetches all EC2 instances belonging to an AWS account and AWS region.
  3. Filter node filters out only those EC2 instances belonging to Dev environment.
  4. User Approval node sends an email to the recipient requesting to Approve or Reject the action that follows.
  5. Action node, upon detecting Approve command, stops all the filtered out EC2 instances.
  6. Notification node sends an email to the concerned team(s) or stakeholder(s) about stopping of Dev EC2 machines.

Steps to Customize this Template

  1. Open the template and check for all the nodes' connectivity.
  2. Double click on Trigger node. Add or modify the following details as per your requirement:
    1. Select the day of the week you want to start the workflow from the drop down menu. Example: Friday. If you want the workflow to start every morning, select all the days of the week.
    2. Select the time of the day, of your choice, from the drop down menu. Example: 21:00 for 9pm
    3. Click on Save Node.
  3. Double click on Resource node. Add or modify the following details as per your requirement:
    1. Select your AWS account from the drop down menu.
    2. Select the AWS region you want to pick the resources from.
    3. Retain the AWS Service name 'EC2' entry.
    4. Retain the AWS Resource name 'Instances' entry.
    If you wish to pick only specific instances or attributes of instances, use Advanced Filters and Add-ons available.
    1. Click on Save Node.
  4. Double click on Filter node. Add or modify the following details as per your requirement:
    1. Retain the Tags selection
    2. Enter the Key and Value if you wish to change. To fine tune the resource filtering further, add more conditions.
    3. Click on Save Node.
  5. Double click on User Approval node. Add or modify the following details as per your requirement:
    1. Enter the receiver's email
    2. Type in the customized message you would like to be sent to the recipient.
    If you do not type in a customized message, TotalCloud will send a default email with Approve or Reject commands.
    1. Click on Save Node.
  6. Double click on Action node. Add or modify the following details as per your requirement:
    1. Select your AWS account from the drop down menu.
    2. Select the AWS region you want to pick the resources from.
    3. Retain the AWS Service name 'EC2' entry.
    4. Retain the Action entry ' Stop Instances.'
    If you wish to pass additional parameters to the node, use Additional Parameters feature.
    1. Click on Save Node.
  7. Double click on Notification node. Add or modify the following details as per your requirement:
    1. Enter the receiver's email
    2. Type in the customized message you would like to be sent to the recipient.
    If you do not type in a customized message, TotalCloud will send a default email about the successful execution.
  8. Click on Save the Workflow.
  9. Click on Validate the Workflow with the policy.
  10. Click on Run Now.


How did we do?