Stop / Start EC2 Instance on a schedule: Difference between revisions
From Cramsession
Jump to navigationJump to search
✍️ Verified Author: Mflavell • Click to view professional profile & credentials
| Line 21: | Line 21: | ||
* edit the section and paste the following between the square brackets in the statement. | * edit the section and paste the following between the square brackets in the statement. | ||
{ | { | ||
"Version": "2012-10-17", | "Version": "2012-10-17", | ||
"Statement": [ | "Statement": [ | ||
| Line 43: | Line 43: | ||
} | } | ||
] | ] | ||
} | } | ||
= Add Lambda functions = | = Add Lambda functions = | ||
= Schedule the functions = | = Schedule the functions = | ||
Revision as of 03:15, 29 March 2025
Introduction
This approach depends on three components.
- AWS IAM for rights
- Lambda to execute the code
- Event bridge to execute the lambda code
Setup rights
Create a new policy in the IAM Console.
- Launch the IAM Console
- Click Policies
- Click Creare policy
- Select JSON (Blue button, top right)
- edit the section and paste the following between the square brackets in the statement.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"ec2:Start*",
"ec2:Stop*"
],
"Resource": "*"
}
]
}