Example SCPs for Amazon Elastic Compute Cloud (Amazon EC2) - AWS Organizations

Example SCPs for Amazon Elastic Compute Cloud (Amazon EC2)

Require Amazon EC2 instances to use a specific type

With this SCP, any instance launches not using the t2.micro instance type are denied.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "RequireMicroInstanceType", "Effect": "Deny", "Action": "ec2:RunInstances", "Resource": [ "arn:aws:ec2:*:*:instance/*" ], "Condition": { "StringNotEquals": { "ec2:InstanceType": "t2.micro" } } } ] }

Prevent launching EC2 instances without IMDSv2

The following policy restricts all users from launching EC2 instances without IMDSv2.

[ { "Effect":"Deny", "Action":"ec2:RunInstances", "Resource":"arn:aws:ec2:*:*:instance/*", "Condition":{ "StringNotEquals":{ "ec2:MetadataHttpTokens":"required" } } }, { "Effect":"Deny", "Action":"ec2:RunInstances", "Resource":"arn:aws:ec2:*:*:instance/*", "Condition":{ "NumericGreaterThan":{ "ec2:MetadataHttpPutResponseHopLimit":"3" } } }, { "Effect":"Deny", "Action":"*", "Resource":"*", "Condition":{ "NumericLessThan":{ "ec2:RoleDelivery":"2.0" } } }, { "Effect":"Deny", "Action":"ec2:ModifyInstanceMetadataOptions", "Resource":"*" } ]

The following policy restricts all users from launching EC2 instances without IMDSv2 but allows specific IAM identities to modify instance metadata options.

[ { "Effect": "Deny", "Action": "ec2:RunInstances", "Resource": "arn:aws:ec2:*:*:instance/*", "Condition": { "StringNotEquals": { "ec2:MetadataHttpTokens": "required" } } }, { "Effect": "Deny", "Action": "ec2:RunInstances", "Resource": "arn:aws:ec2:*:*:instance/*", "Condition": { "NumericGreaterThan": { "ec2:MetadataHttpPutResponseHopLimit": "3" } } }, { "Effect": "Deny", "Action": "*", "Resource": "*", "Condition": { "NumericLessThan": { "ec2:RoleDelivery": "2.0" } } }, { "Effect": "Deny", "Action": "ec2:ModifyInstanceMetadataOptions", "Resource": "*", "Condition": { "ArnNotLike": { "aws:PrincipalARN": [ "arn:aws:iam::{ACCOUNT_ID}:{RESOURCE_TYPE}/{RESOURCE_NAME}" ] } } } ]

Prevent disabling of default Amazon EBS encryption

The following policy restricts all users from disabling the default Amazon EBS Encryption.

{ "Effect": "Deny", "Action": [ "ec2:DisableEbsEncryptionByDefault" ], "Resource": "*" }