With the company compliance policy, I am looking for solution to block the clients (100+ aws accounts) to create ec2 instances with public IPs or try to attach elastic IPs on it after created.
I am thinking to use AWS Organization SCP to implement it, so I don't need set it in individual account. But can't get the proper SCP policy to do it.
A SCP policy for your reference that I can block s3 public access with below policy, I need similar to ec2 instances.
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:PutAccountPublicAccessBlock"
],
"Resource": "*",
"Effect": "Deny"
}
]
}
Idealy, with the proper SCP policy, when client in their account under Orgainzation OU, they can't create ec2 instance if they allow public IP on it, or after created the ec2, when they try to attach elastic IP, the scp should block it.
Updates
Thanks, @john
let me try this policy
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ec2:AssociateAddress"
],
"Resource": "*",
"Effect": "Deny"
}
]
}
update #2
Above scp policy doesn't work, I can still create new instance with public IPs
