1. Create a policy:
a. Click on create policy
b. Paste the below code
{
"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": "*"
} ] }
c. Type the policy name and click on create policy.
2. Create a IAM Role and attach the above policy that we have created.
a. Click on create role.

b. Select the lambda
c. Select the policy that we have created in previous step.

d. Type the role name an click on create role