In order to grant a user for turn on/off of an EC2 instance you have to create a custom policy.
- At first, make sure you’re a root user of AWS.
- Go through the IAM panel.
- Then click on the ‘Policies’ menu on the left sidebar.
-
Then create a policy using the following JSON, just make sure you’ve put the proper EC2 instance id.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "ec2:DescribeInstances", "Resource": "*" }, { "Effect": "Allow", "Action": [ "ec2:StartInstances", "ec2:StopInstances" ], "Resource": "arn:aws:ec2:*:*:instance/<YOU-EC2-INSTANCE-ID>" } ] }
- Review and save the policy.
- Then you have to attach the newly created policy to your new or existing IAM user.
- That’s all.