Thuta Learning
AWS Advanced
Architecture & GovernanceDevOpsAdvanced

AWS Organizations and Service Control Policies (SCPs)

AWS AdvancedLesson 240 min

What you'll walk away with

  • Explain why a multi-account strategy matters and how the management account differs from member accounts
  • Understand that SCPs never grant permissions — effective permissions are an intersection
  • Compare the deny-list and allow-list strategies and choose one
  • Write a region-restricting, guardrail-protecting SCP and test it safely on a test OU

Explain it simply

Explain it simply

In a large company every department has its own office, budget and manager. Head office still sets company-wide rules — 'no department may switch off the fire alarms' — and pays all the departments' invoices from one place.

AWS Organizations is that head office for AWS accounts. Each account is like a separate department, but they share one bill and can be grouped into organizational units (OUs). Service control policies (SCPs) are the company-wide rules — a ceiling on what is allowed that even an administrator inside the account cannot exceed.

Problem → Why → Solution

The problem — everything in one account

Most teams start with one account and keep dev, staging and prod in it. IAM policies then depend on naming conventions such as 'developers can do anything except to resources starting with prod-'. One broken convention — someone names a table production-orders — and the protection disappears.

One account also means shared service quotas: a dev Lambda under load test can eat the concurrency that prod needs. Splitting the bill by team relies on tags, and untagged resources belong to nobody.

dev-policy-single-account.json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DevelopersCanDoEverything",
      "Effect": "Allow",
      "Action": "*",
      "Resource": "*"
    },
    {
      "Sid": "ButPleaseNotProd",
      "Effect": "Deny",
      "Action": ["dynamodb:DeleteTable", "rds:DeleteDBInstance"],
      "Resource": [
        "arn:aws:dynamodb:*:*:table/prod-*",
        "arn:aws:rds:*:*:db:prod-*"
      ]
    }
  ]
}

Why this is fragile

A deny list only protects the actions and name patterns you thought of in advance. It does not stop dynamodb:UpdateTable, rds:ModifyDBInstance, or a developer using iam:* to grant themselves more. The account boundary, by contrast, is AWS's strongest isolation boundary: no permission inside one account reaches another account's resources on its own.

Core concept — organization structure and SCP evaluation

An organization has one management account (the account that created it) and member accounts. Accounts live in OUs under a root, and OUs can be nested up to five levels below the root. Consolidated billing combines every account's usage into one bill, so volume pricing tiers, Savings Plans and Reserved Instance discounts can be shared across accounts.

The main benefit of multiple accounts is blast radius. A leaked credential in a dev account cannot directly touch prod data. Quotas, bills and IAM are separated per account naturally.

Organizations has two feature sets. 'Consolidated billing only' gives you the shared bill and nothing else; 'all features' adds SCPs and other management policies such as tag policies and backup policies. New organizations use all features by default, and everything in this chapter needs it.

An SCP is a JSON policy document that shares most of its grammar with IAM — Effect, Action or NotAction, Resource, Condition — but has no Principal element, because it always applies to every principal in the target accounts. Attach it to an OU and every account in that OU and in every nested OU below it inherits it. Moving an account to another OU changes its guardrails immediately.

Service control policy (SCP)
An organization policy attached to the root, an OU or an account that sets the maximum permissions available to IAM users and roles in the member accounts below it — including each account's root user.

The most important rule: SCPs never grant permissions. For a request to succeed, an SCP must allow it at every level on the path from the root to the account, and an IAM policy must also allow it. Effective permissions are the intersection of these sets. If an SCP allows s3:* but the user has no S3 IAM permission, nothing happens. An explicit deny anywhere always wins.

Remember two exceptions: SCPs do not affect the management account at all, and they do not restrict service-linked roles. That is why you should not run workloads in the management account — your guardrails cannot protect it.

text
SCP INHERITANCE
---------------
  management account  (SCPs never apply here)
         |
      [ Root ]  SCPs: FullAWSAccess + baseline-guardrails
         |
    +----+------------------+
    |                       |
 [ OU: Security ]     [ OU: Workloads ]  SCP: region-guard
    |                   |            |
  log-archive      [ OU: Prod ]  [ OU: NonProd ]
  audit                 |            |
                   orders-prod   orders-dev

 Effective permission of a role in orders-prod =
   SCPs(Root) AND SCPs(Workloads) AND SCPs(Prod)
   AND SCPs(account) AND the role's IAM policies
How SCPs filter a request
  1. Any explicit deny? Then deny
  2. Allowed at every level, root to account?
  3. Does an IAM policy allow it?
  4. All yes: request allowed

Think of an SCP as a filter: it can only remove permissions that IAM would otherwise grant, never add any.

Write a baseline guardrail SCP

This SCP uses the deny-list strategy: keep the default FullAWSAccess policy and add three 'never' statements. It stops accounts leaving the organization, stops anyone stopping or deleting CloudTrail, and blocks activity outside two approved regions. One security-team role is exempted for break-glass work.

baseline-guardrails.json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyLeavingTheOrganization",
      "Effect": "Deny",
      "Action": "organizations:LeaveOrganization",
      "Resource": "*"
    },
    {
      "Sid": "ProtectCloudTrail",
      "Effect": "Deny",
      "Action": [
        "cloudtrail:StopLogging",
        "cloudtrail:DeleteTrail",
        "cloudtrail:UpdateTrail",
        "cloudtrail:PutEventSelectors"
      ],
      "Resource": "*",
      "Condition": {
        "ArnNotLike": {
          "aws:PrincipalARN": "arn:aws:iam::*:role/OrgSecurityAdmin"
        }
      }
    },
    {
      "Sid": "DenyOutsideApprovedRegions",
      "Effect": "Deny",
      "NotAction": [
        "iam:*",
        "organizations:*",
        "sts:*",
        "route53:*",
        "cloudfront:*",
        "support:*",
        "budgets:*",
        "ce:*",
        "health:*",
        "account:*"
      ],
      "Resource": "*",
      "Condition": {
        "StringNotEquals": {
          "aws:RequestedRegion": ["us-east-1", "ap-southeast-1"]
        },
        "ArnNotLike": {
          "aws:PrincipalARN": "arn:aws:iam::*:role/OrgSecurityAdmin"
        }
      }
    }
  ]
}

Code breakdown

  1. DenyLeavingTheOrganization"Action": "organizations:LeaveOrganization"

    If an account leaves the organization, every SCP, consolidated billing and central logging vanish at once. This deny is the guardrail that protects all the other guardrails.

  2. ProtectCloudTrail"ArnNotLike": { "aws:PrincipalARN": "...role/OrgSecurityAdmin" }

    Switching off logging is usually an attacker's first move. This statement blocks even account administrators and exempts only the OrgSecurityAdmin role. aws:PrincipalARN checks the role ARN, and the wildcard account makes it work in every account.

  3. NotAction"NotAction": ["iam:*", "organizations:*", ...]

    Global services such as IAM, Route 53 and CloudFront handle requests through a single region endpoint. NotAction means 'deny everything except these services', so the region rule does not break global services.

  4. aws:RequestedRegion"StringNotEquals": { "aws:RequestedRegion": [...] }

    Deny when the request targets a region outside the list. The two keys in one Condition block are ANDed: the deny applies only when the region is wrong and the caller is not the security admin.

You should see
The policy itself prints nothing. After it is attached to an OU, a developer in orders-dev calling eu-west-1 sees (sample output):

$ aws dynamodb list-tables --region eu-west-1
An error occurred (AccessDeniedException) when calling the ListTables operation: User: arn:aws:sts::111122223333:assumed-role/Developer/alice is not authorized to perform: dynamodb:ListTables on resource: arn:aws:dynamodb:eu-west-1:111122223333:table/* with an explicit deny in a service control policy
Evaluating a member-account request
  1. Request arrives
  2. SCP explicit deny?
  3. SCP allow on whole path?
  4. IAM policy allow?

Passes every step

Allowed

Fails any step

AccessDenied

Deny-list versus allow-list strategy

Deny-listAllow-list
Starting pointKeep FullAWSAccess, add Deny statementsRemove FullAWSAccess, Allow only listed services
New AWS servicesAvailable automaticallyBlocked until added to the list
MaintenanceLow — write only what you forbidHigh — every level needs an allow
Good fitMost organizationsHighly regulated environments

Most organizations start with a deny-list, because an allow-list needs an allow at every level and a policy change every time someone wants a new service. An SCP can be up to 5,120 characters and a target can have up to five SCPs attached, so guardrails are usually combined into a few compact policies.

Resource control policies (RCPs)

SCPs restrict principals. AWS also offers a newer policy type, resource control policies (RCPs), which apply similar guardrails on the resource side for a subset of services such as S3 and KMS. Check the documentation for the current list of supported services before relying on them.

Creating, attaching and safely testing an SCP

A wrong SCP attached at the root can lock out hundreds of accounts at once. Use a test OU with a test account first, watch CloudTrail for AccessDenied events, and only then roll out OU by OU. Run these commands from the management account (or a delegated administrator).

attach-scp.sh
ROOT_ID=$(aws organizations list-roots --query 'Roots[0].Id' --output text)

# SCPs are enabled once per organization (requires "all features")
aws organizations enable-policy-type \
  --root-id "$ROOT_ID" \
  --policy-type SERVICE_CONTROL_POLICY

POLICY_ID=$(aws organizations create-policy \
  --name baseline-guardrails \
  --type SERVICE_CONTROL_POLICY \
  --description "Deny leaving org, protect CloudTrail, restrict regions" \
  --content file://baseline-guardrails.json \
  --query 'Policy.PolicySummary.Id' --output text)

# Attach to a test OU first, never straight to the root
aws organizations attach-policy \
  --policy-id "$POLICY_ID" \
  --target-id ou-a1b2-scptest1

aws organizations list-policies-for-target \
  --target-id ou-a1b2-scptest1 \
  --filter SERVICE_CONTROL_POLICY \
  --query 'Policies[].Name'

Exercise normal work in the test account

Confirm everyday work — deployment pipelines, console sign-in, creating IAM roles — still succeeds.

Test what should be denied

Call a disallowed region and check that the error says 'explicit deny in a service control policy'.

Roll out one OU at a time

Attach in order Sandbox, NonProd, Prod, watching CloudTrail for a few days between OUs.

In production

In real production

Real organizations range from dozens to thousands of accounts, usually one account per workload per environment (orders-dev, orders-prod). A common OU layout is Security (log archive, audit and security tooling), Infrastructure (shared networking, CI/CD), Workloads/Prod and Workloads/NonProd, Sandbox (experiments with budget limits) and Suspended (deny-all for accounts about to be closed).

SCPs are stored in Git and deployed through pull-request review and a pipeline instead of being edited in the console, because one bad SCP can cause an organization-wide outage. The management account is used only for billing and organization administration, with very few people allowed in and MFA enforced. Security tooling is delegated to the security account as a delegated administrator, so nobody needs to work inside the management account day to day. Account creation is usually automated too (Control Tower Account Factory, in the next lesson), so a new account takes minutes and teams are never tempted to share one.

Common mistakes

Common mistakes

Expecting an SCP to grant access

Someone attaches an SCP allowing s3:* to an OU and announces that developers can now use S3. Without an IAM policy granting S3, nothing changes. An SCP is a ceiling; access is granted only through IAM policies or Identity Center permission sets.

Detaching FullAWSAccess without a replacement

Removing FullAWSAccess from an OU to try an allow-list instantly denies every action in every account under that OU. If you move to an allow-list, attach the new allow SCP first and only then detach FullAWSAccess.

Region deny without exempting global services

A region deny on aws:RequestedRegion without a NotAction list can break global services such as IAM, CloudFront, Route 53 and Support, and the roles that services like Control Tower rely on. A similar mistake is running workloads in the management account and assuming SCPs protect them — they never apply there.

💰 Cost & Cleanup

AWS Organizations, OUs and SCPs are free, and this lab only creates an OU and a policy. Creating member accounts is also free, but closed accounts go through a 90-day post-closure period and closures are limited by a quota, so use a test OU rather than creating throwaway accounts. Detach and delete the policy when you finish.

Clean up when you are done

bash
aws organizations detach-policy \
  --policy-id "$POLICY_ID" \
  --target-id ou-a1b2-scptest1
aws organizations delete-policy --policy-id "$POLICY_ID"
# Only if you created the test OU for this lab and it is now empty:
aws organizations delete-organizational-unit \
  --organizational-unit-id ou-a1b2-scptest1

Mini challenge

An instance-type guardrail for the Sandbox OU

People in sandbox accounts keep launching large GPU instances and the bill is climbing. Write an SCP for the Sandbox OU.

  • Deny `ec2:RunInstances` for any instance type other than `t3.*` and `t4g.*`
  • Use the deny-list strategy (keep FullAWSAccess attached)
  • Target only the instance resource, so volumes and network interfaces are not blocked

Expected: In a sandbox account, launching `t3.micro` succeeds and launching `g5.xlarge` fails with an 'explicit deny in a service control policy' error.

Show hint

Use the `ec2:InstanceType` condition key with `StringNotLike`, and set Resource to `arn:aws:ec2:*:*:instance/*`.

Show solution
sandbox-instance-types.json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "OnlySmallInstancesInSandbox",
      "Effect": "Deny",
      "Action": "ec2:RunInstances",
      "Resource": "arn:aws:ec2:*:*:instance/*",
      "Condition": {
        "StringNotLike": {
          "ec2:InstanceType": ["t3.*", "t4g.*"]
        }
      }
    }
  ]
}

Quick quiz 1 / 3

An account's SCPs allow only `s3:*` and `ec2:*`. A role in that account has AdministratorAccess. What happens when it calls `dynamodb:ListTables`?

Quick quiz 2 / 3

An SCP denying `organizations:LeaveOrganization` is attached to the root. Which account does it NOT restrict?

Quick quiz 3 / 3

What is the 'deny-list' SCP strategy?

What to remember

  • The account boundary is the strongest isolation, so use one account per workload and environment
  • SCPs never grant — effective permissions are the intersection of SCPs (root to account) and IAM
  • SCPs do not restrict the management account or service-linked roles
  • Start with a deny-list that blocks leaving the org, disabling CloudTrail and unapproved regions
  • Test every new SCP on a test OU first and deploy it from Git through a pipeline

What is AWS Organizations? — AWS Documentation

Service control policies (SCPs) — AWS Documentation

Organizing Your AWS Environment Using Multiple Accounts — AWS Documentation

Updated on

Progress is saved only in this browser on this device. It isn't synced to other devices.

Report a problem with this lessonOpens your email app with this lesson's address filled in — nothing is sent until you send it.

AWS Organizations and Service Control Policies (SCPs) | Thuta Learning