Skip to content

Instantly share code, notes, and snippets.

@tomofuminijo
Created March 10, 2020 01:43
Show Gist options
  • Save tomofuminijo/d644d0a095fa11e46c2786bc3cce200d to your computer and use it in GitHub Desktop.
Save tomofuminijo/d644d0a095fa11e46c2786bc3cce200d to your computer and use it in GitHub Desktop.
Policy that restrict instance types
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowPolicy",
"Effect": "Allow",
"Action": [
"ec2:*",
"autoscaling:*"
],
"Resouce": "*"
},
{
"Sid": "DenySpecificInstanceTypeOfEC2",
"Effect": "Deny",
"Action": [
"ec2:RunInstances",
"ec2:StartInstances"
],
"Resource": "arn:aws:ec2:*:*:instance/*",
"Condition": {
"StringNotLike": {
"ec2:InstanceType": [
"*.nano",
"*.micro",
"*.small",
"*.medium",
"*.large"
]
}
}
},
{
"Sid": "DenySpecificInstanceTypeOfEC2ForLaunchConfig",
"Effect": "Deny",
"Action": [
"autoscaling:CreateLaunchConfiguration"
],
"Resource": "*",
"Condition": {
"StringNotLike": {
"autoscaling:InstanceType": [
"*.nano",
"*.micro",
"*.small",
"*.medium",
"*.large"
]
}
}
},
{
"Sid": "DenySpecificInstanceTypeOfEC2ForASG",
"Effect": "Deny",
"Action": [
"autoscaling:CreateAutoScalingGroup"
],
"Resource": "*",
"Condition": {
"ForAnyValue:StringNotLikeIfExists": {
"autoscaling:InstanceTypes": [
"*.nano",
"*.micro",
"*.small",
"*.medium",
"*.large"
]
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment