Skip to content

Instantly share code, notes, and snippets.

@wreulicke
Created February 8, 2019 18:42
Show Gist options
  • Save wreulicke/f1cc06c055676a37057174c7ba9ce545 to your computer and use it in GitHub Desktop.
Save wreulicke/f1cc06c055676a37057174c7ba9ce545 to your computer and use it in GitHub Desktop.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:AttachVolume",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:CopyImage",
"ec2:CreateImage",
"ec2:CreateKeypair",
"ec2:CreateSecurityGroup",
"ec2:CreateSnapshot",
"ec2:CreateTags",
"ec2:CreateVolume",
"ec2:DeleteKeyPair",
"ec2:DeleteSecurityGroup",
"ec2:DeleteSnapshot",
"ec2:DeleteVolume",
"ec2:DeregisterImage",
"ec2:DescribeImageAttribute",
"ec2:DescribeImages",
"ec2:DescribeInstances",
"ec2:DescribeRegions",
"ec2:DescribeSecurityGroups",
"ec2:DescribeSnapshots",
"ec2:DescribeSubnets",
"ec2:DescribeTags",
"ec2:DescribeVolumes",
"ec2:DetachVolume",
"ec2:GetPasswordData",
"ec2:ModifyImageAttribute",
"ec2:ModifyInstanceAttribute",
"ec2:ModifySnapshotAttribute",
"ec2:RegisterImage",
"ec2:RunInstances",
"ec2:StopInstances",
"ec2:TerminateInstances"
],
"Resource": "*"
}
]
}
#!/bin/bash
aws iam create-role --role-name $ROLE_NAME --assume-role-policy-document file://assume-role-for-packer-ec2.json
aws --profile personal iam put-role-policy --role-name $ROLE_NAME --policy-document file://packer-ec2-policy.json --policy-name packer-ec2-policy
#!/bin/bash
aws iam create-instance-profile --instance-profile-name $INSTANCE_PROFILE_NAME
aws --profile personal iam add-role-to-instance-profile --instance-profile-name $INSTANCE_PROFILE_NAME --role-name $INSTANCE_PROFILE_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment