Reducing Amazon Elastic Compute Cloud (Amazon EC2) usage by stopping and starting EC2 instances automatically.

How to stop and start Amazon EC2 instances using Lambda Functions and EventBridge/ CloudWatch

  • I AM user credentials to complete the lab
  • At least one Ec2 instance
  • Create Policy and Roles
  • 2 Lambda Functions that start and stop ec2 instances
  • 2 EventBridge/ CloudWatch rules that trigger my Functions on a schedule
Choose Lambda above.
Review policy above.
Add Permission next below.
Click on Create role.
Choose Lambda above.
Click Create function.
Click on Create function.
Click on Deploy above after pasting in the python code.
Click deploy above.
  • Goto CloudWatch console
  • Choose events and select Create rule
  • Select schedule under Event source
Click Create Rule
Click Create Rule.
Click Test to stop instance.
Click test to start instance.
The EventBridge is successfully triggering the Lambda Functions.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Eric Wainwright

DevOps engineer in search of Cloud Engineer role. Looking for Cloud Operations or Cloud Infrastructure opportunities.