Principal-Based Environment Access
Policy Description
What this SCP does
This Service Control Policy (SCP) ensures that only principals with the appropriate environment tag can access resources. This helps enforce environment segregation between production and non-production resources.
By restricting access based on principal tags, this policy creates a clear boundary between production and development environments, ensuring that only properly tagged identities can interact with production resources, which is essential for maintaining security and compliance requirements.
Validation Strategy
How to test this SCP works
To validate this SCP, you need to test with IAM roles that have different environment tags.
- Valid test: Create IAM roles with different environment tags (prod vs. dev)
- Expected result: Operations succeed when performed by principals tagged with Environment=prod, but fail when performed by principals with any other Environment tag value
For thorough testing, you should create EC2 instance profiles for different roles, launch instances with these profiles, and test various AWS operations from each instance to verify the SCP's effectiveness.
SCP Policy & Validation Scenarios
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"StringNotEquals": {
"aws:PrincipalTag/Environment": "prod"
}
}
}
]
}