Another SCP Oddity

,

Trying to understand SCPs for SAP-C02 : I have an Org with ROOT + Management Account and TWO Accounts that inherit from Root: Development and Production. In the Development Account I’m creating the following SCPs:

  1. I have DETACHED the default FullAwsAccess
  2. SCP will ONLY deny any RDS action (create, delete etc) — WORKS
  3. SCP will ONLY allow EC2 to CREATE EC2s if it has the correct tags values — WORKS
  4. SCP will ONLY allow to CREATE EC2s if it has the correct tag keys— DOESNT WORK

Am trying to understand why the 4th SCP in the list of SCPs below which Im attaching to my Development Account is having no effect. I can put ANY tag named say “FOO” It doesnt matter WHAT tag I put in (its supposed to fail since i dont have BOTH “ENV” & “OwnerContact” tabs) but its still allowing me to launch the EC2 Instance. As opposed to say the 3rd SCP which fails correctly if I dont put in the ENV tag with any of the allowed: DEV/QA/PROD!!

SCP 1 FullAWSAccess Detached

SCP 2 Attached Deny Only RDS (Works)

{
“Version”: “2012-10-17”,
“Statement”: [
{
“Sid”: “AllowAllAccess”,
“Effect”: “Allow”,
“Action”: [
“"
],
“Resource”: [
"
”
]
},
{
“Sid”: “DenyRDSAccess”,
“Effect”: “Deny”,
“Action”: [
“rds:"
],
“Resource”: [
"
”
]
}
]
}

SCP 3 Attached Allow Specific Tag Values for ENV Tag Key (Works)

{
“Version”: “2012-10-17”,
“Statement”: [
{
“Sid”: “AllowLaunchEC2OnlyWithENVTag”,
“Effect”: “Deny”,
“Action”: “ec2:RunInstances”,
“Resource”: “arn:aws:ec2:::instance/*”,
“Condition”: {
“StringNotEquals”: {
“aws:RequestTag/ENV”: [
“DEV”,
“QA”,
“PROD”
]
}
}
}
]
}

SCP 4 Attached Allow Only Specific Tags (Doesn’t Work)

{
“Version”: “2012-10-17”,
“Statement”: [
{
“Sid”: “AlowOnlySpecificTags”,
“Effect”: “Deny”,
“Action”: [
“ec2:RunInstances”
],
“Resource”: [
“arn:aws:ec2:::instance/*”
],
“Condition”: {
“ForAllValues:StringNotEquals”: {
“aws:TagKeys”: [
“ENV”,
“OwnerContact”
]
}
}
}
]
}


Related discussions:

Your 4th policy denies ec2:RunInstances on any EC2 instance where the tag does not equal ENV and OwnerContact.

Is that the intention?

yes this SCP mandates you need both ENV and OwnerContact tags to be present