Created
December 28, 2016 16:38
-
-
Save timoguin/6ef7c4c0da82c30496e9ea044e79ee47 to your computer and use it in GitHub Desktop.
IAM policy for the Packer Builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "NonResourceBasedReadOnlyPermissions", | |
"Effect": "Allow", | |
"Action": [ | |
"ec2:DescribeVolumes", | |
"ec2:DescribeKeyPairs", | |
"ec2:DescribeSecurityGroups", | |
"ec2:DescribeSubnets", | |
"ec2:DescribeSnapshots", | |
"ec2:DescribeInstances", | |
"ec2:DescribeImages" | |
], | |
"Resource": "*" | |
}, | |
{ | |
"Sid": "NonResourceBasedReadOnlyPermissionsForSpotInstanceUsage", | |
"Effect": "Allow", | |
"Action": [ | |
"ec2:DescribeSpotPriceHistory", | |
"ec2:DescribeSpotInstanceRequests" | |
], | |
"Resource": "*" | |
}, | |
{ | |
"Sid": "NonResourceBasedWritePermissions", | |
"Effect": "Allow", | |
"Action": [ | |
"ec2:RegisterImage", | |
"ec2:ModifyInstanceAttribute", | |
"ec2:ModifyImageAttribute", | |
"ec2:DeleteSnapshot", | |
"ec2:DeleteKeyPair", | |
"ec2:CreateVolume", | |
"ec2:CreateTags", | |
"ec2:CreateSnapshot", | |
"ec2:CreateSecurityGroup", | |
"ec2:CreateKeyPair", | |
"ec2:CreateImage", | |
"ec2:CopyImage" | |
], | |
"Resource": "*" | |
}, | |
{ | |
"Sid": "NonResourceBasedWritePermissionsForSpotInstanceUsage", | |
"Effect": "Allow", | |
"Action": [ | |
"ec2:RequestSpotInstances", | |
"ec2:CancelSpotInstanceRequests" | |
], | |
"Resource": "*" | |
}, | |
{ | |
"Sid": "IAMPassroleToInstance", | |
"Effect": "Allow", | |
"Action": "iam:PassRole", | |
"Resource": "arn:aws:iam::111111111111:role/PackerBuilder" | |
}, | |
{ | |
"Sid": "AllowInstanceActions", | |
"Effect": "Allow", | |
"Action": [ | |
"ec2:TerminateInstances", | |
"ec2:StopInstances", | |
"ec2:DetachVolume", | |
"ec2:AttachVolume" | |
], | |
"Resource": "arn:aws:ec2:us-east-1:111111111111:instance/*", | |
"Condition": { | |
"StringEquals": { | |
"ec2:InstanceProfile": "arn:aws:iam::111111111111:instance-profile/packer_builder" | |
} | |
} | |
}, | |
{ | |
"Sid": "EC2RunInstances", | |
"Effect": "Allow", | |
"Action": "ec2:RunInstances", | |
"Resource": "arn:aws:ec2:us-east-1:111111111111:instance/*", | |
"Condition": { | |
"StringEquals": { | |
"ec2:InstanceProfile": "arn:aws:iam::111111111111:instance-profile/packer_builder" | |
} | |
} | |
}, | |
{ | |
"Sid": "EC2RunInstancesSubnet", | |
"Effect": "Allow", | |
"Action": "ec2:RunInstances", | |
"Resource": "arn:aws:ec2:us-east-1:111111111111:subnet/*", | |
"Condition": { | |
"StringEquals": { | |
"ec2:vpc": "arn:aws:ec2:us-east-1:111111111111:vpc/vpc-11111111" | |
} | |
} | |
}, | |
{ | |
"Sid": "RemainingRunInstancePermissions", | |
"Effect": "Allow", | |
"Action": "ec2:RunInstances", | |
"Resource": [ | |
"arn:aws:ec2:us-east-1::snapshot/*", | |
"arn:aws:ec2:us-east-1::image/*", | |
"arn:aws:ec2:us-east-1:111111111111:volume/*", | |
"arn:aws:ec2:us-east-1:111111111111:subnet/*", | |
"arn:aws:ec2:us-east-1:111111111111:security-group/*", | |
"arn:aws:ec2:us-east-1:111111111111:network-interface/*", | |
"arn:aws:ec2:us-east-1:111111111111:key-pair/*" | |
] | |
}, | |
{ | |
"Sid": "EC2VpcNonresourceSpecificActions", | |
"Effect": "Allow", | |
"Action": [ | |
"ec2:DeleteSecurityGroup", | |
"ec2:AuthorizeSecurityGroupIngress" | |
], | |
"Resource": "*", | |
"Condition": { | |
"StringEquals": { | |
"ec2:vpc": "arn:aws:ec2:us-east-1:111111111111:vpc/vpc-11111111" | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This allows Packer to launch instances in a specific VPC with a specific instance profile, and only terminate those.