Sub topic 13
Testing and rolling out guardrails safely
This chapter assumes you can read SCP and RCP JSON, know how policies inherit down the organization tree, and can use the AWS CLI with management-account credentials. A new guardrail can block production workloads the moment you attach it, so you roll it out in stages.
Why staged rollout matters
SCPs and RCPs take effect on every principal or resource under the target. There is no audit mode. If you attach a policy to the root and it is wrong, every account in the organization is affected. The only way to limit that risk is to limit where you attach the policy first.
The rollout path
Step 1: Build a test OU
Create an OU that holds one or two non-production accounts, and move an account into it.
aws organizations create-organizational-unit \
--parent-id r-examplerootid \
--name PolicyTest
aws organizations move-account \
--account-id 111122223333 \
--source-parent-id r-examplerootid \
--destination-parent-id ou-exam-ple12345Step 2: Find out what the policy would break
Before attaching a deny, check whether anyone uses the action or Region you are about to block.
- Search CloudTrail for the action or Region. For a Region restriction, look for events whose
awsRegionis outside your approved list. - Check IAM last accessed information for the accounts and OUs, to see which services are in use.
- Ask workload owners about services that run in the background, such as scheduled jobs and cross-account automation.
Step 3: Attach to the test OU and verify both ways
Attach the policy to the test OU, as in the earlier chapter on attaching policies. Then run one request that should be denied and one that should still work, from a principal in the test account.
aws organizations attach-policy \
--policy-id p-examplepolicyid \
--target-id ou-exam-ple12345
# Should fail with the Region SCP from the earlier chapter
aws ec2 describe-instances --region us-east-1
# Should succeed
aws ec2 describe-instances --region eu-west-1The denied call returns an error that contains the phrase explicit deny in a service control policy. For an RCP, the phrase is resource control policy. If the allowed call also fails, the policy is broader than you intended.
Test the exceptions as well. A Region SCP with a NotAction list should still allow IAM and Route 53 calls. A data perimeter RCP should still allow your approved partners.
Step 4: Widen in steps
Move to a pilot OU of low-risk accounts, wait long enough for scheduled jobs to run (at least a week for weekly jobs), and check CloudTrail for new access denied events. Then attach to production OUs, and to the root last. If a new policy only needs to cover some accounts, attach it to those OUs and leave the root alone.
Rolling back
Detaching removes the effect right away. Keep the command ready before you attach.
aws organizations detach-policy \
--policy-id p-examplepolicyid \
--target-id ou-exam-ple12345Common mistakes
| Mistake | Result | Prevention |
|---|---|---|
| Attaching first to the root | Organization-wide outage on error | Start at a test OU |
| Testing only the denied path | Over-broad denial goes unnoticed | Also test an allowed call |
| Testing as an administrator | Misses cases that depend on a specific role | Test with the roles real workloads use |
| Testing in the management account | SCPs and RCPs do not restrict it, so the test proves nothing | Use a member account |
Exercise
You wrote an SCP that denies all actions outside eu-west-1 and eu-central-1. Describe how you would roll it out, including one test that should be denied, one that should succeed, and how you would undo it.
Show answer
Create a test OU with a non-production member account and attach the SCP there. From that account, run aws ec2 describe-instances --region us-east-1, which should fail with an explicit deny in a service control policy. Run the same command with --region eu-west-1, which should succeed, and call a global service such as IAM to confirm the NotAction exemption works. Check CloudTrail for other Regions in use before widening, then attach to a pilot OU, then production OUs. To undo it, run aws organizations detach-policy with the policy ID and the target ID.