Skip to content

SCP Cloudformation organization policy with condition

0

are condition supported in AWS::Organizations::Policy

asked a year ago243 views

1 Answer
1

Yes, conditions are supported in AWS::Organizations::Policy when creating Service Control Policies (SCPs) through CloudFormation.

SCPs use a syntax similar to IAM policies and can include Condition elements in their policy statements. The Condition element allows you to specify circumstances under which the policy statement is in effect.

For example, you can use conditions in SCPs to:

  1. Restrict access based on AWS regions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"NotAction": [
"cloudfront:*",
"iam:*",
"route53:*",
"support:*"
],
"Resource": "*",
"Condition": {
"StringNotEquals": {
"aws:RequestedRegion": [
"eu-central-1",
"eu-west-1"
]
}
}
}
]
}
  1. Create time-based restrictions using conditions like aws:CurrentTime:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": "s3:*",
"Resource": "*",
"Condition": {
"DateGreaterThan": {
"aws:CurrentTime": "2024-09-11T00:00:00Z"
}
}
}
]
}
  1. Control access based on principal ARNs:
{
"Effect": "Deny",
"NotAction": [
"budgets:*",
"support:*",
"waf:*"
],
"Resource": "*",
"Condition": {
"ArnNotLike": {
"aws:PrincipalARN": [
"arn:aws:iam::*:role/abc",
"arn:aws:iam::*:role/cde"
]
}
}
}

When defining these policies in CloudFormation, you would include the condition elements as part of the policy content in your template.
Sources
SCP syntax - AWS Organizations
AWS SCP time based | AWS re:Post
SCP policy with negative condition | AWS re:Post

answered a year ago

EXPERT

reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.