Skip to main content

Command Palette

Search for a command to run...

Minimal AWS Policy for creating instances

Published
1 min readView as Markdown
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ec2:Describe*",
                "ec2:Get*",
                "ec2:List*",
                "ec2:CreateTags",
                "ec2:CreateSecurityGroup",
                "ec2:AuthorizeSecurityGroupIngress",
                "ec2:AuthorizeSecurityGroupEgress",
                "ec2:CreateKeyPair",
                "ec2:CreateVolume",
                "ec2:AttachVolume",
                "ec2:DescribeVolumes",
                "ec2:DeleteVolume",
                "ec2:RunInstances"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Deny",
            "Action": "ec2:RunInstances",
            "Resource": "*",
            "Condition": {
                "ForAnyValue:StringNotLike": {
                    "ec2:InstanceType": "t3.medium"
                },
                "StringEquals": {
                    "aws:RequestedRegion": "eu-north-1"
                }
            }
        }
    ]
}

This limits the creation to a specified type and a specified region. Remove the conditions if no limits are intended.