As an administrator, you often have several operational tasks that you have to perform on a regular basis. A vast array of these tasks can be performed through automation. This can be used for both ongoing processes that you need to perform or project-related. In this video, we explain a use case for automating the start and stop of EC2 Instances using both AWS Lambda and Amazon EventBridge. This is often useful when you are working with On-Demand EC2 Instances where perhaps the instances need not be in the running state 24/7. You can automate the state and stop of your EC2 instances only when required and thus save on usage costs as part of your overall cost optimization pillar of the AWS Well-Architected Framework.

AWS Lambda is a serverless compute offering designed to help you build serverless and event-driven applications. AWS Lambda functions can be triggered by a wide range of AWS services to perform some compute action on your AWS resources. Amazon EventBridge is a serverless event bus solution that can deliver a stream of data from an event source to targets such as AWS Lambda, Amazon SNS and SQS among others. AWS EventBridge can also help you schedule triggers for your targets as is the case in this hands-on demonstration using Cron schedules.

This video demonstrates how to set up and configure AWS Lambda and EventBridge to automatically start and stop your EC2 Instances at designated times, Mondays to Friday and fulfils a typical use case where we wish to ensure that On-Demand instances are only placed in the running state when needed for daily operational tasks.

This video also comes with a sample IAM Policy to help you define your Lambda Execution Role as well as the actual python code to help you build your Lambda function to automatically start and stop your EC2 instances.

Link: https://github.com/iaasacademy/aws-how-to-guide/tree/main/LambdaEC2StartStop

Close Popup

We use cookies to give you the best online experience. By agreeing you accept the use of cookies in accordance with our cookie policy.

Close Popup
Privacy Settings saved!
Privacy Settings

When you visit any web site, it may store or retrieve information on your browser, mostly in the form of cookies. Control your personal Cookie Services here.

These cookies are necessary for the website to function and cannot be switched off in our systems.

Technical Cookies
In order to use this website we use the following technically required cookies
  • wordpress_test_cookie
  • wordpress_logged_in_
  • wordpress_sec

WooCommerce
We use WooCommerce as a shopping system. For cart and order processing 2 cookies will be stored. This cookies are strictly necessary and can not be turned off.
  • woocommerce_cart_hash
  • woocommerce_items_in_cart

Decline all Services
Save
Accept all Services
Open Privacy settings