1 Answer
- Newest
- Most votes
- Most comments
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:
- 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" ] } } } ] }
- 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" } } } ] }
- 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
Relevant content
asked 3 years ago
asked 2 years ago
