Steps to Setup Lambda to Start / Stop EC2 instances: 1) Create a Lambda Function with 'Author from scratch' and with Function name 'ecStartInstance' and Runtime 'Python 3.8' 2) Choose new role with basic Lambda permission 3) Create policy using IAM role 4) Click on JSON Editor option and update EC2 instance policy json and click on 'Review Policy' JSON: { "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": "*" } ] } 5) Give name
Comments
Post a Comment