Skip to content

Instantly share code, notes, and snippets.

@scottnixonjr
Created April 16, 2020 18:13
Show Gist options
  • Save scottnixonjr/5c983905d4b872782bb5b65c3909864e to your computer and use it in GitHub Desktop.
Save scottnixonjr/5c983905d4b872782bb5b65c3909864e to your computer and use it in GitHub Desktop.
Project Based Access for creating EC2 Instances. Policy for Solution 1 in Developer Sandboxes - https://github.com/stelligent/developer-sandboxes
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "ec2:RunInstances",
"Resource": [
"arn:aws:ec2:*:*:instance/*"
],
"Condition": {
"StringEquals": {
"aws:RequestTag/project": "vahalla"
},
"ForAllValues:StringEquals": {
"aws:TagKeys": "project"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateTags"
],
"Resource": "arn:aws:ec2:*:*:*/*",
"Condition": {
"StringEquals": {
"ec2:CreateAction": "RunInstances"
}
}
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "ec2:CreateTags",
"Resource": "arn:aws:ec2:*:*:instance/*",
"Condition": {
"StringEquals": {
"ec2:ResourceTag/project": "vahalla"
},
"ForAllValues:StringEquals": {
"aws:TagKeys": "project"
},
"StringEqualsIfExists": {
"aws:RequestTag/project": "vahalla"
}
}
},
{
"Sid": "VisualEditor2",
"Effect": "Allow",
"Action": [
"ec2:StartInstances",
"ec2:StopInstances"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"ec2:ResourceTag/project": "vahalla"
}
}
},
{
"Sid": "VisualEditor3",
"Effect": "Allow",
"Action": "ec2:RunInstances",
"Resource": [
"arn:aws:ec2:*:*:subnet/*",
"arn:aws:ec2:*:*:key-pair/*",
"arn:aws:ec2:*:*:launch-template/*",
"arn:aws:ec2:*::snapshot/*",
"arn:aws:ec2:*:*:volume/*",
"arn:aws:ec2:*:*:security-group/*",
"arn:aws:ec2:*:*:placement-group/*",
"arn:aws:ec2:*:*:network-interface/*",
"arn:aws:ec2:*::image/*"
]
},
{
"Sid": "PermissionsForRunningTestsOnly",
"Effect": "Allow",
"Action": [
"sts:DecodeAuthorizationMessage",
"cloudformation:ListExports"
],
"Resource": "*"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment