Interview Prep/DevSecOps/Cloud Security, CIS and Compliance

Write an SCP that restricts usage to approved regions.

AdvancedConceptCloud Security, CIS and Compliance
Answer

SCPs set the maximum permissions for accounts in an OU; they grant nothing. Global services must be exempted with NotAction or they break.

{
  "Version": "2012-10-17",
  "Statement": [{
    "Sid": "DenyOutsideApprovedRegions",
    "Effect": "Deny",
    "NotAction": ["iam:*", "organizations:*", "sts:*", "route53:*",
                  "cloudfront:*", "support:*", "budgets:*"],
    "Resource": "*",
    "Condition": {
      "StringNotEquals": { "aws:RequestedRegion": ["ap-south-1", "eu-west-1"] },
      "ArnNotLike": { "aws:PrincipalARN": "arn:aws:iam::*:role/OrgBreakGlass" }
    }
  }]
}

Other common SCPs: deny leaving the organisation, deny disabling CloudTrail/GuardDuty/Config, deny root user actions, require IMDSv2 on ec2:RunInstances. SCPs do not apply to the management account, so keep workloads out of it.

All DevSecOps questions Roadmap: Policy as code

More on Cloud Security, CIS and Compliance