This template
provides a streamlined solution for automatically shutting down EC2 instances
in your AWS region, promoting cost savings
and resource efficiency. The template includes the essential resources and configurations for scheduled shutdowns. Notably, the flexibility of the "exception" tag
allows you to exclude specific instances
, tailoring the solution to your needs. Deploy effortlessly in your preferred AWS region to manage EC2 shutdowns with ease, optimizing infrastructure
, reducing costs
, and enhancing overall resource management.
AWS Account
EC2 Instances in Running/Stopped State
- Login in to the
AWS Console
and search forCloudFormation
- Click on
Create stack
--->With new resources (standard)
- Choose
Template is ready
--->Upload a template file
--->Choose file
and click onNext
- Give the stack some
name
---> ec2-instance-auto-shutdown - Configure the settings as per your need (optional) and click on
Submit
- Once the Stack is successfully created, click on
Resources
tab to view all the newly created resource (Lambda Function, IAM Role and Event Rule) - Now the
Event Rule
will trigger the Lambda function based on thecron job
(by default it is MON-FRI 5 PM UTC) - You can also manually test the lambda function by creating a sample
test event
and running it.
- The exclusion of auto shutdown of instances is based on the tag "exception" attached to the instance, irrespective of the case.
![Screenshot 2024-01-28 at 9 14 09 PM](https://private-user-images.githubusercontent.com/56265949/300276610-83ce1061-bc53-493a-a822-b27752e8a0f5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4MzczODIsIm5iZiI6MTcyMzgzNzA4MiwicGF0aCI6Ii81NjI2NTk0OS8zMDAyNzY2MTAtODNjZTEwNjEtYmM1My00OTNhLWE4MjItYjI3NzUyZThhMGY1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE2VDE5MzgwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBjYzI4ZmJmZWU1NGIwOWE5NjQwYmYzZDMxNGE5YWM5NTZiMzQ1YjVjYzE4NjAyYjU2YjVkMmQ0MGJjZGFjY2ImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.5TAHMedPRqLCj27IwywP5V4_jDHLHB1aCX8r1QM92n8)
![Screenshot 2024-01-28 at 9 42 36 PM](https://private-user-images.githubusercontent.com/56265949/300276710-dcda0cfc-cb79-449d-9f10-287b6a1aeeab.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4MzczODIsIm5iZiI6MTcyMzgzNzA4MiwicGF0aCI6Ii81NjI2NTk0OS8zMDAyNzY3MTAtZGNkYTBjZmMtY2I3OS00NDlkLTlmMTAtMjg3YjZhMWFlZWFiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE2VDE5MzgwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE0NTRkNTBlODFkMzA1NTY3Nzg3MDY3NWVlMTdiZTJkODZiYjIyMTE1NWZiMmQ4ZjJjYzI5M2JmNzJlMjQxZTYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.1oWkWlyWGIxWUhN6exHVuTOtNi9BdbhEFc4Wj-p27l8)
![Screenshot 2024-01-28 at 9 43 21 PM](https://private-user-images.githubusercontent.com/56265949/300276772-fe3444f3-6d4d-4d64-b731-9b241a9fa7f0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4MzczODIsIm5iZiI6MTcyMzgzNzA4MiwicGF0aCI6Ii81NjI2NTk0OS8zMDAyNzY3NzItZmUzNDQ0ZjMtNmQ0ZC00ZDY0LWI3MzEtOWIyNDFhOWZhN2YwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE2VDE5MzgwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ4YzZhZGNjYzI4ZDczOTBkZDA3OGI5MzkyOTAzMmRiZTg5YTAzN2MxYTg2ZjkyMWExNGVkNDEyNGY5ZGVkYjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.0u7UBJVFbH3UqgUsXscqP2tTw9qmdA8DLib3slDTnzk)
![Screenshot 2024-01-28 at 9 44 52 PM](https://private-user-images.githubusercontent.com/56265949/300276880-e5996af4-2daa-454f-a5d6-925d24e35f13.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4MzczODIsIm5iZiI6MTcyMzgzNzA4MiwicGF0aCI6Ii81NjI2NTk0OS8zMDAyNzY4ODAtZTU5OTZhZjQtMmRhYS00NTRmLWE1ZDYtOTI1ZDI0ZTM1ZjEzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE2VDE5MzgwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZiYmJiMTk3ZmJhOTJlMjBmMjc2ZjlhMGJjMmNlMTEyMTJjZDg3MmI1MzZlODgzNTlmODAyYWE2YWEyZWNiOTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.kcWhmym4i4FzmK11jukIzxYGW5mkj9ZLhaItbY7x7-Y)
![Screenshot 2024-01-28 at 9 45 15 PM](https://private-user-images.githubusercontent.com/56265949/300276906-468c56f3-81d1-4bb5-9a3a-375631f524b1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4MzczODIsIm5iZiI6MTcyMzgzNzA4MiwicGF0aCI6Ii81NjI2NTk0OS8zMDAyNzY5MDYtNDY4YzU2ZjMtODFkMS00YmI1LTlhM2EtMzc1NjMxZjUyNGIxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE2VDE5MzgwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYzNWU1NTM1M2I1ZTI2YjE4NWY4ZTViZTRhZWEyM2I2YTQyY2U4ODkxMzhhNTY2NTUxOGVmOGVlNzRjNTJmZjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.OKFirjLLAnaX-OLXHRzY-40vws_9SNWCt_NaJt0cVPs)