Skip to content

Instantly share code, notes, and snippets.

@atheiman
Created October 2, 2023 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atheiman/4d082d5449f163ee9e62a7b20dd52849 to your computer and use it in GitHub Desktop.
Save atheiman/4d082d5449f163ee9e62a7b20dd52849 to your computer and use it in GitHub Desktop.
Service Control Policy (SCP) to restrict using Transit Gateway Attachment or Gateway Load Balancer Endpoint (inspection) subnets
{
"Version":"2012-10-17",
"Statement": [
{
"Effect":"Deny",
"Action": [
"ec2:AssociateClientVpnTargetNetwork",
"ec2:AssociateRouteTable",
"ec2:AssociateSubnetCidrBlock",
"ec2:AssociateTransitGatewayMulticastDomain",
"ec2:CreateClientVpnRoute",
"ec2:CreateFleet",
"ec2:CreateFlowLogs",
"ec2:CreateInstanceConnectEndpoint",
"ec2:CreateNatGateway",
"ec2:CreateNetworkInterface",
"ec2:CreateSubnet",
"ec2:CreateTags",
"ec2:CreateTransitGatewayVpcAttachment",
"ec2:CreateVerifiedAccessEndpoint",
"ec2:CreateVpcEndpoint",
"ec2:DeleteClientVpnRoute",
"ec2:DeleteSubnet",
"ec2:DeleteTags",
"ec2:DisassociateRouteTable",
"ec2:DisassociateSubnetCidrBlock",
"ec2:DisassociateTransitGatewayMulticastDomain",
"ec2:ImportInstance",
"ec2:ModifyFleet",
"ec2:ModifySpotFleetRequest",
"ec2:ModifySubnetAttribute",
"ec2:ModifyTransitGatewayVpcAttachment",
"ec2:ModifyVerifiedAccessEndpoint",
"ec2:ModifyVpcEndpoint",
"ec2:ReplaceNetworkAclAssociation",
"ec2:ReplaceRouteTableAssociation",
"ec2:RequestSpotFleet",
"ec2:RequestSpotInstances",
"ec2:RunInstances"
],
"Resource":"arn:aws:ec2:*:*:subnet/*",
"Condition": {
"StringEquals": {
"ec2:ResourceTag/SubnetFunction": [
"TransitGatewayAttachment",
"GatewayLoadBalancerEndpoint"
]
},
"StringNotLike": {
"aws:PrincipalArn": [
"arn:aws:iam::*:role/AWSControlTowerExecution",
"arn:aws:iam::*:role/OrganizationAccountAccessRole"
]
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment