EC2 instance turn on/off policy

In order to grant a user for turn on/off of an EC2 instance you have to create a custom policy.

  1. At first, make sure you’re a root user of AWS.
  2. Go through the IAM panel.
  3. Then click on the ‘Policies’ menu on the left sidebar.
  4. 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>"
            }
        ]
    }
  5. Review and save the policy.
  6. Then you have to attach the newly created policy to your new or existing IAM user.
  7. That’s all.
Posted in: AWS