Skip to content

Instantly share code, notes, and snippets.

@sjoerdsmink
sjoerdsmink / stop-ec2.yaml
Created July 31, 2022 11:14
Stopping EC2 instances when not in use
# See https://sjoerdsmink.medium.com/saving-energy-and-money-stopping-ec2-instances-when-not-in-use-c8e44eb7f6b6 for full story
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
EC2InstanceId:
Type: 'String'
Description: 'EC2 Instance ID, for example i-1234567890abcdef0'
Resources:
# Optional CloudWatch alarm when CPU < 20% for 50 minutes
CPUAlarm:
Type: AWS::CloudWatch::Alarm