Permission boundaries, SCPs, RCPs and resource-based policies
Delegate IAM safely with permission boundaries, set organisation-wide guardrails with SCPs and RCPs, and use resource-based policies to build a data perimeter and controlled cross-account access.
Assumes: .NET 10 LTS · AWS SDK for .NET v4 (AWSSDK.IdentityManagement 4.1.1.2) · AWS CLI v2 · Region us-east-1. Verified against official sources on 2026-11-17.
Learning objectives
By the end of this lesson you can:
- Explain the difference between policies that grant permissions (identity-based and resource-based policies) and policies that only cap them (permission boundaries, SCPs, RCPs, session policies).
- Build a permission boundary that lets a developer create IAM roles for their own Lambda functions without being able to escalate their own privileges (Lab 5.2).
- Write service control policies (SCPs) and resource control policies (RCPs), know who and what they do not apply to, and roll them out safely.
- Write resource-based policies for S3, KMS, SQS, Secrets Manager and Lambda, and configure cross-account access correctly.
- Describe the three parts of a data perimeter (identity, resource and network) and the condition keys that implement them.
Prerequisites
- IAM in depth — policy grammar, policy types and ARNs
- Policy evaluation logic — how all policy types combine into one decision
- Identity Center, MFA and STS — you sign in with the
learn-sandboxprofile - Secure your AWS account — you created an organisation and a sandbox account with an SCP
- Tools: AWS CLI v2, .NET 10 SDK (for the C# simulator), a text editor
Why this matters in banking
Harbourline Bank has 40 product teams. The platform team cannot hand-craft every IAM role that every Lambda function needs; that bottleneck turns into weeks of waiting and, eventually, someone asking for AdministratorAccess "just for the pilot". But if developers can create roles freely, any developer can create a role with AdministratorAccess, assume it, and read the payments database. That is a privilege escalation path, and an auditor will find it in minutes.
At the same time, the bank must guarantee things no account administrator can switch off: CloudTrail stays on, data stays in approved Regions, no S3 bucket in the organisation is readable by an AWS account outside Harbourline, and customer data cannot be copied to a personal AWS account. Regulators (and the bank's own risk function) want these to be preventive controls, not just alerts after the fact.
This lesson gives you the three tools for those problems: permission boundaries (safe delegation inside an account), SCPs and RCPs (guardrails across the organisation), and resource-based policies (who may touch a specific resource, including from other accounts).
The idea in plain language
There are two kinds of IAM policies:
- Policies that grant. An identity-based policy ("this role may read this table") or a resource-based policy ("this bucket may be read by that role") actually gives access.
- Policies that cap. A permission boundary, an SCP, an RCP or a session policy can only remove access. They say "whatever else you have been given, you can never go beyond this line". On their own, they grant nothing.
The effective permission is the overlap: an action must be granted by something and not be outside any cap and not be explicitly denied anywhere.
- A permission boundary caps one IAM user or role.
- An SCP caps every IAM user and role (including the root user) in the member accounts it is attached to.
- An RCP caps what anyone — inside or outside the organisation — can do to resources in the member accounts it is attached to.
- A resource-based policy lives on a resource (bucket, key, queue, secret, function) and both grants and restricts access to it, including for other accounts.
Analogy: Think of Harbourline's head office building. The keycard (identity policy) says which doors you may open. The vault door has its own list of who may enter (resource policy). Your contract caps your authority — a junior teller's contract says "never more than £5,000 per transaction" whatever keycard you are given (permission boundary). Head office rules cap every branch — "no branch may open on Sundays" (SCP). And a building rule caps every room — "no visitor without a Harbourline badge may enter any vault" (RCP). Nobody can be authorised beyond the strictest of these.
What problem each control solves
| Control | Attached to | Grants? | Caps whom | Typical banking use | Sharp edges |
|---|---|---|---|---|---|
| Identity-based policy | User, group, role | Yes | — | "Payments API role may write to the payments table" | Easy to over-grant with wildcards |
| Resource-based policy | S3 bucket, KMS key, SQS queue, SNS topic, secret, Lambda function, role trust policy, … | Yes | Anyone named in Principal | Cross-account log delivery, KMS key access | Only some services support them; KMS key policies are mandatory |
| Permission boundary | One user or role | No | That user or role | Developers creating roles for their own functions | Must be attached at creation and protected from removal |
| SCP | Organisation root, OU, member account | No | IAM users and roles in member accounts, including the member root user | Region restriction, "never stop CloudTrail", "never leave the organisation" | Does not affect the management account or service-linked roles; max 10,240 characters; up to 10 attached per target |
| RCP | Organisation root, OU, member account | No | Any principal acting on resources in member accounts | "Only Harbourline principals may access our S3, KMS, SQS and secrets", "TLS only" | Only some services; Deny only; Principal must be "*"; max 5,120 characters; up to 5 per target (including the mandatory RCPFullAWSAccess) |
| Session policy | One STS session | No | That session | A broker issuing narrow, short-lived credentials | Passed by the caller, so it is only as trusted as the caller |
| Declarative policy | Organisation root, OU, account | n/a | Service configuration | "Block public access for all VPCs", "IMDSv2 by default", allowed AMIs | Configures services rather than filtering API calls; supports a growing list of services |
Facts in this table were checked on 2026-11-17 against the AWS Organizations user guide pages for SCPs, RCPs and quotas. The CloudFormation reference for AWS::Organizations::Policy lists 5,120 characters for SCPs, while the Organizations quota page lists 10,240 ⚠ VERIFY which limit applies to SCPs created through CloudFormation; keep SCPs well under 5,120 characters to be safe.
Who SCPs and RCPs do not affect
Memorise this list; it appears in exam questions and real incidents alike:
- The management account. Neither SCPs nor RCPs restrict principals or resources in the management account. This is why you keep workloads out of it.
- Service-linked roles. Roles that AWS services create for themselves (
AWSServiceRoleFor…) are not restricted by SCPs or RCPs. - RCPs and AWS managed KMS keys. RCPs do not apply to AWS managed keys (the
aws/s3,aws/secretsmanagerstyle keys), because you cannot change their permissions anyway. Another reason banks use customer managed keys. - SCPs and principals outside the organisation. An SCP on account A does not limit an external account B user reading account A's bucket. That gap is exactly what RCPs close.
SCPs do restrict the root user of member accounts. RCPs do restrict root users too, and they apply regardless of whether the caller belongs to your organisation.
Microsoft / Azure comparison
| You know (Microsoft/Azure) | AWS equivalent | What's different |
|---|---|---|
Azure Policy with deny effect at management group | SCP on an OU | SCPs filter IAM API permissions; they do not inspect resource properties after creation the way Azure Policy audit/deny can |
Azure Policy deny for public network access / storage firewall | RCP (plus S3 Block Public Access, declarative policies) | RCPs evaluate on every request to the resource, from any caller, including other tenants' principals |
Azure RBAC role with NotActions / custom role limits for delegated admins | Permission boundary | A boundary is a separate policy that caps a role; the role's permission policy still has to grant |
| Entra ID PIM "role assignment eligibility" and admin units | Permission boundary + session duration + separate permission sets | AWS has no built-in admin unit; boundaries and account separation do that job |
| Storage account access policy, Key Vault access policy / RBAC on the vault | S3 bucket policy, KMS key policy, Secrets Manager resource policy | KMS key policy is mandatory and is the root of trust for the key |
| Azure Lighthouse / cross-tenant access | Cross-account role assumption or resource policy naming the other account | Both sides must allow: the caller's identity policy and the resource's policy (or the role's trust policy) |
Private endpoints + Deny public network access | VPC endpoints + aws:SourceVpce conditions in resource policies | Network restriction is written into the policy, not only into the network |
Architecture
Security-boundary view. Three different lines are drawn:
- Organisation line (SCPs and RCPs): nothing inside a member account can exceed the SCPs, and nothing outside the organisation can reach member-account resources that RCPs protect.
- Account line: the account is the strongest isolation unit. Crossing it always needs an allow on both sides.
- Delegation line (boundaries): inside the payments-dev account, the developer can create roles, but only roles stamped with the application boundary, so nothing they create can do more than the boundary allows.
Part A — Permission boundaries and Lab 5.2
How a boundary works
A permission boundary is a managed policy you attach to a user or role in a special slot (PermissionsBoundary). For a request by that principal, the identity-based policy must allow the action and the boundary must allow it. An explicit deny in either wins.
Two subtleties matter in a bank:
- Same-account resource policies. If a resource-based policy in the same account names an IAM user ARN directly, an implicit deny in that user's boundary does not block it. If it names an IAM role ARN, the boundary still applies. If it names a role session ARN, the permission goes straight to the session and the boundary's implicit deny does not limit it. Explicit denies always win. In practice: put explicit
Denystatements in boundaries for anything that must never happen, and do not grant same-account resource access to session ARNs. - A boundary does nothing unless it is mandatory. The whole trick is the
iam:PermissionsBoundarycondition key: the developer may calliam:CreateRoleonly if the request attaches your boundary. Without that condition, the developer simply creates a role without a boundary.
The escalation paths you must close
When you let someone manage IAM, list the ways they could escalate and close each one:
| Escalation path | How it works | How the lab closes it |
|---|---|---|
| Create a role with no boundary | iam:CreateRole without PermissionsBoundary | Allow CreateRole only with iam:PermissionsBoundary = app boundary |
| Remove the boundary later | iam:DeleteRolePermissionsBoundary | Explicit deny on that action |
| Swap to a weaker boundary | iam:PutRolePermissionsBoundary with another policy | Same condition key on PutRolePermissionsBoundary |
| Edit the boundary policy itself | iam:CreatePolicyVersion / SetDefaultPolicyVersion on the boundary | Explicit deny on the boundary policy ARNs |
| Modify their own role | iam:AttachRolePolicy on hl-m05-developer | Role-management actions only on the path /hl-m05-app/ |
| Pass a powerful existing role to a service | iam:PassRole on * | PassRole only for /hl-m05-app/* roles and only to lambda.amazonaws.com |
| Create access keys for others | iam:CreateAccessKey | Not granted (no IAM users at all) |
Architecture of the lab
Step-by-step implementation (Lab 5.2)
Everything in this lab is IAM, which has no charge. Use your sandbox account with the learn-sandbox profile. Replace 111122223333 with your sandbox account ID (aws sts get-caller-identity --profile learn-sandbox).
Write the application boundary
This boundary is what every role a developer creates will carry. It allows only what Harbourline application functions normally need, only on hl-m05-* resources, and explicitly denies dangerous actions.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAppDataPlane",
"Effect": "Allow",
"Action": [
"dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem",
"sqs:SendMessage", "sqs:ReceiveMessage", "sqs:DeleteMessage", "sqs:GetQueueAttributes"
],
"Resource": [
"arn:aws:dynamodb:us-east-1:111122223333:table/hl-m05-*",
"arn:aws:sqs:us-east-1:111122223333:hl-m05-*"
]
},
{
"Sid": "AllowOwnLogs",
"Effect": "Allow",
"Action": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents"],
"Resource": "arn:aws:logs:us-east-1:111122223333:log-group:/aws/lambda/hl-m05-*"
},
{
"Sid": "NeverIamOrOrgOrAuditTampering",
"Effect": "Deny",
"Action": [
"iam:*", "organizations:*", "sts:AssumeRole",
"cloudtrail:StopLogging", "cloudtrail:DeleteTrail", "kms:ScheduleKeyDeletion"
],
"Resource": "*"
}
]
}Write the developer's own boundary and permission policy
The developer role also gets a boundary, so that even if someone later attaches AdministratorAccess to it, it still cannot escape. The permission policy and the boundary are deliberately almost identical here; in production the boundary is broader (the "maximum ever") and the permission policy is narrower (the "today").
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CreateAndChangeAppRolesOnlyWithBoundary",
"Effect": "Allow",
"Action": [
"iam:CreateRole", "iam:PutRolePermissionsBoundary",
"iam:AttachRolePolicy", "iam:DetachRolePolicy",
"iam:PutRolePolicy", "iam:DeleteRolePolicy"
],
"Resource": "arn:aws:iam::111122223333:role/hl-m05-app/*",
"Condition": {
"StringEquals": {
"iam:PermissionsBoundary": "arn:aws:iam::111122223333:policy/hl-m05-app-boundary"
}
}
},
{
"Sid": "ManageAppRolesNoBoundaryChange",
"Effect": "Allow",
"Action": [
"iam:GetRole", "iam:ListRolePolicies", "iam:ListAttachedRolePolicies",
"iam:TagRole", "iam:DeleteRole", "iam:UpdateAssumeRolePolicy"
],
"Resource": "arn:aws:iam::111122223333:role/hl-m05-app/*"
},
{
"Sid": "PassAppRolesToLambdaOnly",
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::111122223333:role/hl-m05-app/*",
"Condition": { "StringEquals": { "iam:PassedToService": "lambda.amazonaws.com" } }
},
{
"Sid": "ReadOnlyIamForConsole",
"Effect": "Allow",
"Action": ["iam:GetPolicy", "iam:GetPolicyVersion", "iam:ListPolicies", "iam:ListRoles"],
"Resource": "*"
},
{
"Sid": "DenyBoundaryRemoval",
"Effect": "Deny",
"Action": ["iam:DeleteRolePermissionsBoundary", "iam:DeleteUserPermissionsBoundary"],
"Resource": "*"
},
{
"Sid": "DenyEditingBoundaryPolicies",
"Effect": "Deny",
"Action": [
"iam:CreatePolicyVersion", "iam:DeletePolicy", "iam:DeletePolicyVersion", "iam:SetDefaultPolicyVersion"
],
"Resource": [
"arn:aws:iam::111122223333:policy/hl-m05-app-boundary",
"arn:aws:iam::111122223333:policy/hl-m05-developer-boundary"
]
}
]
}Save the same file as hl-m05-developer-boundary.json for this lab (the boundary for the developer role itself).
Create the policies and the developer role
Run the CLI commands in the AWS CLI section below. The developer role trusts your own account; your SSO admin role can assume it.
Predict, then test
Before running each test, write down "allow" or "deny" and why. Then assume the developer role and run the four tests in the CLI section. Finally, run the C# simulator, which asks IAM's policy simulator for the same answers without creating anything.
Clean up
Run the teardown commands in Cost and cleanup. IAM is free, but unused roles are attack surface.
AWS Console instructions
- Console → IAM → Policies → Create policy → JSON. Paste
hl-m05-app-boundary.json, name ithl-m05-app-boundary. Repeat forhl-m05-developer-boundaryandhl-m05-developer-policy. - IAM → Roles → Create role → Custom trust policy. Use a trust policy that trusts
arn:aws:iam::111122223333:root. Name ithl-m05-developer. Attachhl-m05-developer-policy. - On the new role, open Permissions boundary → Set permissions boundary and choose
hl-m05-developer-boundary. - Add tags
Project=cea-lab,Lab=m05-boundaries,Environment=learn,Owner=<you>. - To test in the console: account menu → Switch role, enter the account ID and
hl-m05-developer. Then try IAM → Roles → Create role with and without the boundary under Set permissions boundary.
For SCPs and RCPs (management account only): Console → AWS Organizations → Policies → Service control policies / Resource control policies → Enable (once), then Create policy, then Targets → Attach to an OU.
AWS CLI
# Who am I and which account? Use this ID everywhere below.
ACCOUNT=$(aws sts get-caller-identity --query Account --output text --profile learn-sandbox)
TAGS='Key=Project,Value=cea-lab Key=Lab,Value=m05-boundaries Key=Environment,Value=learn Key=Owner,Value=alex'
# Replace the placeholder account ID inside the JSON files (Git Bash / WSL).
sed -i "s/111122223333/$ACCOUNT/g" hl-m05-app-boundary.json hl-m05-developer-boundary.json hl-m05-developer-policy.json
# Create the three customer managed policies.
for p in hl-m05-app-boundary hl-m05-developer-boundary hl-m05-developer-policy; do
aws iam create-policy --policy-name "$p" --policy-document "file://$p.json" \
--tags $TAGS --profile learn-sandbox
done
# Trust policy: principals in this account (with IAM permission to assume) may assume the role.
cat > trust-self.json <<EOF
{ "Version": "2012-10-17",
"Statement": [{ "Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::$ACCOUNT:root" },
"Action": "sts:AssumeRole" }] }
EOF
# Create the developer role WITH its own boundary in the same call.
aws iam create-role --role-name hl-m05-developer \
--assume-role-policy-document file://trust-self.json \
--permissions-boundary "arn:aws:iam::$ACCOUNT:policy/hl-m05-developer-boundary" \
--max-session-duration 3600 --tags $TAGS --profile learn-sandbox
aws iam attach-role-policy --role-name hl-m05-developer \
--policy-arn "arn:aws:iam::$ACCOUNT:policy/hl-m05-developer-policy" --profile learn-sandboxAdd a profile that assumes the developer role (in %USERPROFILE%\.aws\config):
[profile hl-m05-developer]
role_arn = arn:aws:iam::111122223333:role/hl-m05-developer
source_profile = learn-sandbox
region = us-east-1Now the four tests. Lambda trust policy for the roles the developer creates:
cat > trust-lambda.json <<'EOF'
{ "Version": "2012-10-17",
"Statement": [{ "Effect": "Allow",
"Principal": { "Service": "lambda.amazonaws.com" },
"Action": "sts:AssumeRole" }] }
EOF
# Test 1 — create a role WITHOUT the boundary. Expect: AccessDenied.
aws iam create-role --path /hl-m05-app/ --role-name hl-m05-try1 \
--assume-role-policy-document file://trust-lambda.json --profile hl-m05-developer
# Test 2 — create a role WITH the app boundary. Expect: success.
aws iam create-role --path /hl-m05-app/ --role-name hl-m05-try2 \
--assume-role-policy-document file://trust-lambda.json \
--permissions-boundary "arn:aws:iam::$ACCOUNT:policy/hl-m05-app-boundary" \
--profile hl-m05-developer
# Test 3 — attach AdministratorAccess to it. Expect: success (!) — but read on.
aws iam attach-role-policy --role-name hl-m05-try2 \
--policy-arn arn:aws:iam::aws:policy/AdministratorAccess --profile hl-m05-developer
# Prove the cap: simulate what try2 can actually do (run as the learner, not the developer).
aws iam simulate-principal-policy \
--policy-source-arn "arn:aws:iam::$ACCOUNT:role/hl-m05-app/hl-m05-try2" \
--action-names s3:ListAllMyBuckets iam:CreateUser sqs:SendMessage \
--resource-arns "arn:aws:sqs:us-east-1:$ACCOUNT:hl-m05-payments" \
--query 'EvaluationResults[].[EvalActionName,EvalDecision]' --output table --profile learn-sandbox
# Test 4 — try to remove or weaken the boundary. Expect: AccessDenied for both.
aws iam delete-role-permissions-boundary --role-name hl-m05-try2 --profile hl-m05-developer
aws iam create-policy-version --policy-arn "arn:aws:iam::$ACCOUNT:policy/hl-m05-app-boundary" \
--policy-document file://hl-m05-developer-policy.json --set-as-default --profile hl-m05-developerWhat you should see: tests 1 and 4 fail with AccessDenied; the simulator shows sqs:SendMessage allowed (granted by AdministratorAccess and inside the boundary) while s3:ListAllMyBuckets is implicitDeny (outside the boundary) and iam:CreateUser is explicitDeny (denied by the boundary). Attaching AdministratorAccess succeeded, but it is harmless: the boundary decides the ceiling.
SCP and RCP commands (management account)
# Run these with a management-account profile (e.g. learn-mgmt) — SCPs/RCPs are org-level.
ROOT_ID=$(aws organizations list-roots --query 'Roots[0].Id' --output text --profile learn-mgmt)
# Enable RCPs once for the organisation (SCPs were enabled in Module 0).
aws organizations enable-policy-type --root-id "$ROOT_ID" \
--policy-type RESOURCE_CONTROL_POLICY --profile learn-mgmt
# Create an RCP from a file and attach it to the Sandbox OU only (test before the root!).
aws organizations create-policy --name hl-rcp-perimeter --type RESOURCE_CONTROL_POLICY \
--description "Identity perimeter + TLS for supported services" \
--content file://hl-rcp-perimeter.json --profile learn-mgmt
aws organizations attach-policy --policy-id p-examplercp1 --target-id ou-abcd-sandbox1 --profile learn-mgmt
# Which policies apply to an account, including inherited ones?
aws organizations list-policies-for-target --target-id 111122223333 \
--filter RESOURCE_CONTROL_POLICY --profile learn-mgmtPart B — SCPs and RCPs in depth
A baseline SCP for Harbourline
SCPs are best used as deny lists on top of the default FullAWSAccess policy. Each statement protects something the bank must never lose. The break-glass exception uses aws:PrincipalArn so that only the security team's emergency role can change these controls.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyLeavingOrganisation",
"Effect": "Deny",
"Action": "organizations:LeaveOrganization",
"Resource": "*"
},
{
"Sid": "ProtectAuditTrail",
"Effect": "Deny",
"Action": [
"cloudtrail:StopLogging", "cloudtrail:DeleteTrail", "cloudtrail:UpdateTrail",
"cloudtrail:PutEventSelectors"
],
"Resource": "*",
"Condition": {
"ArnNotLike": { "aws:PrincipalArn": "arn:aws:iam::*:role/hl-security-breakglass" }
}
},
{
"Sid": "ProtectDetectionServices",
"Effect": "Deny",
"Action": [
"guardduty:DeleteDetector", "guardduty:DisassociateFromAdministratorAccount",
"securityhub:DisableSecurityHub", "config:StopConfigurationRecorder",
"config:DeleteConfigurationRecorder"
],
"Resource": "*",
"Condition": {
"ArnNotLike": { "aws:PrincipalArn": "arn:aws:iam::*:role/hl-security-breakglass" }
}
},
{
"Sid": "NoLongLivedIamUserKeys",
"Effect": "Deny",
"Action": ["iam:CreateUser", "iam:CreateAccessKey"],
"Resource": "*",
"Condition": {
"ArnNotLike": { "aws:PrincipalArn": "arn:aws:iam::*:role/hl-security-breakglass" }
}
}
]
}Notes:
ArnNotLikewithaws:PrincipalArnmatches the role ARN even when the caller is an assumed-role session — that is why you useaws:PrincipalArnrather thanaws:useridor the session ARN.- SCP
Allowstatements may only use"Resource": "*"; individual ARNs work only inDenystatements. Conditions andNotActionare allowed in both. PrincipalandNotPrincipalare not supported in SCPs — the principals are implicitly "every IAM user and role in the account".
An identity-perimeter RCP
The classic RCP says: "no one outside Harbourline may access our resources, unless it is an AWS service acting for us, and every request must use TLS".
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "EnforceOrgIdentityPerimeter",
"Effect": "Deny",
"Principal": "*",
"Action": ["s3:*", "sqs:*", "kms:*", "secretsmanager:*", "sts:AssumeRole"],
"Resource": "*",
"Condition": {
"StringNotEqualsIfExists": { "aws:PrincipalOrgID": "o-a1b2c3d4e5" },
"BoolIfExists": { "aws:PrincipalIsAWSService": "false" }
}
},
{
"Sid": "EnforceTls",
"Effect": "Deny",
"Principal": "*",
"Action": ["s3:*", "sqs:*", "kms:*", "secretsmanager:*"],
"Resource": "*",
"Condition": { "BoolIfExists": { "aws:SecureTransport": "false" } }
}
]
}How to read the first statement: deny the action if the caller's organisation is not ours and the caller is not an AWS service principal. …IfExists makes the condition true when the key is missing, so a request from a service principal (which has no aws:PrincipalOrgID) is handled by the second key instead. Real banks then add exceptions for third parties they genuinely trust (a payment processor's account, a SIEM vendor reading a log bucket) using aws:PrincipalAccount lists — each exception is a documented risk decision.
RCP rules (verified 2026-11-17):
- Custom RCPs may only use
"Effect": "Deny";Allowexists only in the AWS-managedRCPFullAWSAccess, which is attached everywhere automatically and cannot be detached. Principalmust be"*"; use conditions to target principals.NotPrincipalandNotActionare not supported.- You cannot use
"*"as the wholeAction; you must name a service, e.g."s3:*". - RCPs apply only to supported services. The list started with S3, STS, KMS, SQS and Secrets Manager in November 2024 and now includes many more (for example DynamoDB, ECR, CloudWatch Logs, SNS, EventBridge, Cognito, AWS WAF). Check the list before relying on an RCP for a service.
Rolling out guardrails without breaking production
AWS itself recommends not attaching SCPs or RCPs to the organisation root without testing. Use service last accessed data (IAM → Organizations activity) to see which services an OU actually uses before you deny others.
Declarative policies
Declarative policies are a newer Organizations policy type that sets a service configuration and keeps it, rather than filtering API calls. For EC2 they can, for example, block public access for VPCs, enforce IMDSv2 defaults, and restrict allowed AMIs. Because they are enforced in the service's control plane, they keep working when the service adds new APIs, and unlike SCPs and RCPs they also govern service-linked roles. They complement SCPs; they do not replace them.
Part C — Resource-based policies and cross-account access
A resource-based policy has a Principal element. When the principal is in the same account, either the identity policy or the resource policy is enough (with the boundary and session caveats above). When the principal is in another account, both sides must allow: the caller's identity policy in account A and the resource policy in account B.
The resource policies you will meet most
| Resource | Policy name | Banking example | Gotcha |
|---|---|---|---|
| S3 bucket | Bucket policy | Deny non-TLS, deny access not via the bank's VPC endpoint, allow CloudTrail delivery | Keep Block Public Access on; use Object Ownership "bucket owner enforced" so ACLs are disabled |
| KMS key | Key policy (mandatory) | Only the payments role may Decrypt; only the key-admin role may administer | If the key policy does not delegate to the account (arn:aws:iam::ACCOUNT:root), IAM policies in that account have no effect on the key |
| SQS queue | Queue policy | Allow only the bank's SNS topic to send, using aws:SourceArn | Without aws:SourceArn/aws:SourceAccount, a service principal can be used as a confused deputy |
| Secrets Manager secret | Resource policy | Allow a role in the DR account to read a replicated secret | Cross-account access needs a customer managed KMS key; the aws/secretsmanager key cannot be shared |
| Lambda function | Function policy (add-permission) | Allow API Gateway (one specific API ARN) to invoke | Always set --source-arn; otherwise any API Gateway in any account could try to invoke it |
| IAM role | Trust policy | Allow a partner account to assume a read-only role with an external ID | Trust policy is the resource policy of a role; sts:ExternalId prevents confused deputy |
Example — a network-restricted, TLS-only bucket policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyNonTls",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::hl-m05-statements-111122223333",
"arn:aws:s3:::hl-m05-statements-111122223333/*"
],
"Condition": { "Bool": { "aws:SecureTransport": "false" } }
},
{
"Sid": "DenyOutsideBankNetwork",
"Effect": "Deny",
"Principal": "*",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::hl-m05-statements-111122223333/*",
"Condition": {
"StringNotEqualsIfExists": { "aws:SourceVpce": "vpce-0a1b2c3d4e5f67890" },
"BoolIfExists": { "aws:ViaAWSService": "false" },
"ArnNotLike": { "aws:PrincipalArn": "arn:aws:iam::111122223333:role/hl-security-breakglass" }
}
}
]
}The second statement is a network perimeter: object reads and writes must arrive through the bank's VPC endpoint, unless an AWS service is calling on the bank's behalf (aws:ViaAWSService) or it is the break-glass role. Conditions inside one statement are ANDed, so the deny applies only when all three are true.
The data perimeter in one table
| Perimeter | Question it answers | Where to enforce | Key condition |
|---|---|---|---|
| Identity | Only trusted identities can access my resources | RCP, resource policies | aws:PrincipalOrgID, aws:PrincipalIsAWSService |
| Resource | My identities can access only trusted resources | SCP, VPC endpoint policies | aws:ResourceOrgID |
| Network | Access only from expected networks | Resource policies, RCP, SCP, endpoint policies | aws:SourceVpce, aws:SourceVpc, aws:SourceIp, aws:ViaAWSService |
A resource-perimeter SCP stops a compromised payments role from copying data out to an attacker-owned bucket:
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "OnlyOrgOwnedS3AndSqs",
"Effect": "Deny",
"Action": ["s3:PutObject", "s3:GetObject", "sqs:SendMessage"],
"Resource": "*",
"Condition": {
"StringNotEqualsIfExists": { "aws:ResourceOrgID": "o-a1b2c3d4e5" },
"BoolIfExists": { "aws:PrincipalIsAWSService": "false" }
}
}]
}AWS publishes worked examples in the data perimeter policy examples repository (MIT-0); test every exception against your own service usage before you rely on them.
Infrastructure as Code
using Amazon.CDK;
using Amazon.CDK.AWS.IAM;
using Constructs;
namespace Harbourline.Security.Infra;
public sealed class BoundaryDelegationStack : Stack
{
public BoundaryDelegationStack(Construct scope, string id, IStackProps? props = null)
: base(scope, id, props)
{
// 1. The boundary every developer-created app role must carry.
var appBoundary = new ManagedPolicy(this, "AppBoundary", new ManagedPolicyProps
{
ManagedPolicyName = "hl-m05-app-boundary",
Statements = new[]
{
new PolicyStatement(new PolicyStatementProps
{
Sid = "AllowAppDataPlane",
Actions = new[] { "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:Query",
"sqs:SendMessage", "sqs:ReceiveMessage", "sqs:DeleteMessage" },
Resources = new[]
{
$"arn:aws:dynamodb:{Region}:{Account}:table/hl-m05-*",
$"arn:aws:sqs:{Region}:{Account}:hl-m05-*"
}
}),
new PolicyStatement(new PolicyStatementProps
{
Sid = "NeverIamOrOrg",
Effect = Effect.DENY,
Actions = new[] { "iam:*", "organizations:*", "sts:AssumeRole" },
Resources = new[] { "*" }
})
}
});
// 2. The developer role, itself capped by a boundary (reuse for brevity).
var developer = new Role(this, "Developer", new RoleProps
{
RoleName = "hl-m05-developer",
AssumedBy = new AccountRootPrincipal(),
MaxSessionDuration = Duration.Hours(1),
PermissionsBoundary = CreateDeveloperBoundary(appBoundary)
});
developer.AddToPolicy(new PolicyStatement(new PolicyStatementProps
{
Sid = "CreateAppRolesOnlyWithBoundary",
Actions = new[] { "iam:CreateRole", "iam:PutRolePermissionsBoundary",
"iam:AttachRolePolicy", "iam:PutRolePolicy" },
Resources = new[] { $"arn:aws:iam::{Account}:role/hl-m05-app/*" },
Conditions = new Dictionary<string, object>
{
["StringEquals"] = new Dictionary<string, object>
{
["iam:PermissionsBoundary"] = appBoundary.ManagedPolicyArn
}
}
}));
developer.AddToPolicy(new PolicyStatement(new PolicyStatementProps
{
Sid = "DenyBoundaryTampering",
Effect = Effect.DENY,
Actions = new[] { "iam:DeleteRolePermissionsBoundary", "iam:CreatePolicyVersion",
"iam:SetDefaultPolicyVersion", "iam:DeletePolicyVersion" },
Resources = new[] { "*" }
}));
foreach (var (k, v) in new[] { ("Project", "cea-lab"), ("Lab", "m05-boundaries"),
("Environment", "learn"), ("Owner", "alex") })
{
Amazon.CDK.Tags.Of(this).Add(k, v);
}
}
// The developer's boundary must allow the IAM actions it delegates, so it is a separate policy.
private IManagedPolicy CreateDeveloperBoundary(ManagedPolicy appBoundary) =>
new ManagedPolicy(this, "DeveloperBoundary", new ManagedPolicyProps
{
ManagedPolicyName = "hl-m05-developer-boundary",
Statements = new[]
{
new PolicyStatement(new PolicyStatementProps
{
Actions = new[] { "iam:CreateRole", "iam:PutRolePermissionsBoundary",
"iam:AttachRolePolicy", "iam:PutRolePolicy", "iam:GetRole",
"iam:PassRole", "iam:ListRoles", "iam:GetPolicy", "iam:GetPolicyVersion" },
Resources = new[] { "*" }
}),
new PolicyStatement(new PolicyStatementProps
{
Effect = Effect.DENY,
Actions = new[] { "iam:DeleteRolePermissionsBoundary", "iam:CreatePolicyVersion",
"iam:SetDefaultPolicyVersion", "iam:DeletePolicyVersion" },
Resources = new[] { appBoundary.ManagedPolicyArn, $"arn:aws:iam::{Account}:role/*" }
})
}
});
}CDK also offers PermissionsBoundary.Of(scope).Apply(policy), an aspect that stamps a boundary on every role in a stack or app — useful when the platform team gives product teams a CDK template. Organization policies (SCPs/RCPs) are deployed from the management or delegated-admin account with the L1 construct Amazon.CDK.AWS.Organizations.CfnPolicy and Type = "RESOURCE_CONTROL_POLICY" or "SERVICE_CONTROL_POLICY".
Complete code
This console app asks the IAM policy simulator (SimulateCustomPolicy) how a role carrying the app boundary would be treated, without creating any resources. It is free and is a good regression test: put it in CI so a change to the boundary that suddenly allows iam:CreateUser fails the build.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<RootNamespace>Harbourline.Security.BoundarySimulator</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AWSSDK.IdentityManagement" Version="4.1.1.2" />
<PackageReference Include="AWSSDK.SSO" Version="4.1.0.2" />
<PackageReference Include="AWSSDK.SSOOIDC" Version="4.1.0.2" />
</ItemGroup>
</Project>using Amazon;
using Amazon.IdentityManagement;
using Amazon.IdentityManagement.Model;
using Amazon.Runtime.CredentialManagement;
namespace Harbourline.Security.BoundarySimulator;
internal static class Program
{
// Each case: the action, the resource, and the decision we EXPECT.
private static readonly (string Action, string Resource, string Expected)[] Cases =
[
("sqs:SendMessage", "arn:aws:sqs:us-east-1:111122223333:hl-m05-payments", "allowed"),
("dynamodb:GetItem", "arn:aws:dynamodb:us-east-1:111122223333:table/hl-m05-accounts", "allowed"),
("s3:ListAllMyBuckets", "*", "implicitDeny"),
("iam:CreateUser", "*", "explicitDeny"),
("sts:AssumeRole", "arn:aws:iam::111122223333:role/hl-security-breakglass", "explicitDeny"),
];
private static async Task<int> Main(string[] args)
{
var boundaryFile = args.Length > 0 ? args[0] : "hl-m05-app-boundary.json";
var boundary = await File.ReadAllTextAsync(boundaryFile);
// The "worst case" identity policy: someone attached AdministratorAccess.
const string adminPolicy = """
{ "Version": "2012-10-17",
"Statement": [{ "Effect": "Allow", "Action": "*", "Resource": "*" }] }
""";
var chain = new CredentialProfileStoreChain();
if (!chain.TryGetAWSCredentials("learn-sandbox", out var credentials))
{
Console.Error.WriteLine("Profile 'learn-sandbox' not found. Run: aws sso login --profile learn-sandbox");
return 2;
}
using var iam = new AmazonIdentityManagementServiceClient(credentials, RegionEndpoint.USEast1);
var failures = 0;
foreach (var (action, resource, expected) in Cases)
{
var response = await iam.SimulateCustomPolicyAsync(new SimulateCustomPolicyRequest
{
PolicyInputList = [adminPolicy],
PermissionsBoundaryPolicyInputList = [boundary],
ActionNames = [action],
ResourceArns = [resource]
});
var result = (response.EvaluationResults ?? []).Single();
var actual = result.EvalDecision.Value;
var ok = string.Equals(actual, expected, StringComparison.OrdinalIgnoreCase);
if (!ok) failures++;
Console.WriteLine($"{(ok ? "PASS" : "FAIL"),-5} {action,-22} expected {expected,-13} got {actual}");
}
Console.WriteLine(failures == 0
? "Boundary behaves as designed."
: $"{failures} case(s) differ — review the boundary before merging.");
return failures == 0 ? 0 : 1;
}
}Run it with dotnet run -- hl-m05-app-boundary.json after aws sso login --profile learn-sandbox. The IAM policy simulator is free to call; it creates nothing. The module's lab project contains a fuller offline linter and simplified evaluator at labs/m05-secure-banking-api/src/Harbourline.Security.PolicyLinter with sample policies in policies/.
Code explained line by line
Cases— a table-driven test: each tuple is an action, a resource ARN, and the decision IAM should return. Writing expectations before calling AWS is the habit you want for guardrails.boundaryFile/File.ReadAllTextAsync— the boundary JSON is read from disk, the same file you deploy, so the test cannot drift from reality.adminPolicy— a raw string literal (""") containingAllow * on *. We deliberately simulate the worst-case identity policy to prove the boundary alone is enough.CredentialProfileStoreChain().TryGetAWSCredentials("learn-sandbox", …)— resolves your SSO profile from~/.aws/config. TheAWSSDK.SSOandAWSSDK.SSOOIDCpackages must be referenced, or SSO profiles fail at runtime.new AmazonIdentityManagementServiceClient(credentials, RegionEndpoint.USEast1)— IAM is a global service; its endpoint lives inus-east-1.SimulateCustomPolicyAsync— the policy simulator API.PolicyInputListis the identity policy;PermissionsBoundaryPolicyInputListis the boundary;ActionNamesandResourceArnsdescribe the request.response.EvaluationResults ?? []— in SDK for .NET v4, collection properties arenullwhen the service returns nothing, so always guard with?? [].result.EvalDecision.Value— one ofallowed,explicitDenyorimplicitDeny.explicitDenymeans aDenystatement matched;implicitDenymeans nothing allowed it (here: the boundary did not include it).- The return code (
0/1) lets a pipeline fail the build when a boundary change weakens the guardrail.
What the simulator does not model
SimulateCustomPolicy evaluates the policies you pass in. It does not include SCPs or RCPs from your organisation; SimulatePrincipalPolicy includes SCPs that apply to the account in some cases ⚠ VERIFY current RCP support in the simulator. Always confirm a guardrail with a real call in a test account, and watch CloudTrail.
Security considerations
⚠ Learning shortcut — not for production
The developer role trusts arn:aws:iam::ACCOUNT:root, so any principal in the sandbox account with sts:AssumeRole permission can use it. In production, developers reach this role through an IAM Identity Center permission set (for example PaymentsDeveloper) and the trust policy names the SSO role pattern with aws:PrincipalArn, plus aws:MultiFactorAuthPresent where applicable.
⚠ Learning shortcut — not for production
The RCP and SCP examples use a single break-glass role and a hard-coded organisation ID. In production, break-glass use triggers an alarm (EventBridge rule on AssumeRole for that role), is time-boxed, and is reviewed by a second person. Organisation IDs and exception account lists live in version control with change approval.
- Boundaries are not a substitute for review. A boundary caps the blast radius, but anything inside the boundary is still available to every role the developer creates. Keep the boundary as narrow as the platform allows and review it like code.
- Guard the guardrails. Every policy that implements a control must be protected from modification by the people it constrains: deny
CreatePolicyVersionon boundaries, keep SCP/RCP management in the management or a delegated security account. - Remember the management account gap. Nothing in this lesson protects the management account. Keep it empty of workloads, and give very few people access.
- Validate before deploy. Run IAM Access Analyzer
validate-policy(and custom policy checks) in the pipeline; see Least privilege in practice. - Shared responsibility. AWS guarantees that SCPs, RCPs and boundaries are enforced as documented (security of the cloud). Choosing the right guardrails, testing them and proving to auditors that they work is the bank's job (security in the cloud). These guardrails support, but do not by themselves satisfy, any regulatory requirement — your security architecture and compliance teams decide that.
Banking use case
Harbourline's payments platform team publishes a "golden" CDK library. Every stack it produces applies hl-app-boundary to all roles using PermissionsBoundary.Of(app).Apply(...). Product teams get the PaymentsDeveloper permission set in their dev and test accounts, which lets them create roles only with that boundary — so a new fraud-scoring Lambda gets its own least-privilege role in minutes, without a ticket.
At organisation level, the Workloads OU has hl-scp-baseline (no leaving the org, no stopping CloudTrail, GuardDuty or Config, no IAM users or access keys) and a Region SCP (only eu-west-2 and us-east-1 for global services). The root has hl-rcp-perimeter, with one documented exception: the account of the bank's card processor (fictional "Tidewater Card Services") may read objects under settlement-files/ in one bucket. Production accounts additionally carry a resource-perimeter SCP so a compromised workload cannot write customer data to buckets outside the organisation. The security team reviews AccessDenied events for these guardrails weekly; repeated denials usually mean either an attack or a legitimate need that should become a documented exception.
Common mistakes
- Boundary without the
iam:PermissionsBoundarycondition → developers simply create roles without it → always pair delegation permissions with that condition key. - Forgetting
PutRolePermissionsBoundaryandDeleteRolePermissionsBoundary→ a developer replaces or removes the boundary after creation → condition on the first, explicit deny on the second. iam:PassRoleon*→ a developer passes the bank's admin role to an EC2 instance and uses it → limitPassRoleby path andiam:PassedToService.- Attaching a new SCP to the root first → every account loses access to a service it needed, including pipelines → roll out OU by OU.
- Expecting SCPs to protect the management account → they do not → keep workloads out of it.
- Writing an RCP with
Effect: Allowor a specificPrincipal→ creation fails → custom RCPs are Deny-only with"Principal": "*". - Cross-account access with only one side configured →
AccessDenied→ both identity policy (caller's account) and resource policy (resource's account) must allow; for SSE-KMS, the key policy too. - Sharing a secret encrypted with
aws/secretsmanagercross-account → cannot be decrypted by the other account → use a customer managed KMS key. - Lambda permission without
--source-arn→ any API in any account could attempt invocation → always scope service principals withaws:SourceArn/aws:SourceAccount.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
AccessDenied … with an explicit deny in a service control policy | An SCP blocks the action | Find the SCP with list-policies-for-target; check Region conditions and exceptions |
AccessDenied … with an explicit deny in a resource control policy | An RCP blocks access to the resource | Check aws:PrincipalOrgID/TLS conditions; is the caller an AWS service without aws:PrincipalIsAWSService? |
… because no permissions boundary allows the … action | Action not in the boundary | Add to the boundary (after review) or use a different role |
CreateRole denied even with the boundary | Wrong boundary ARN, or role path not /hl-m05-app/ | Compare ARNs exactly; the condition is StringEquals |
MalformedPolicyDocument when creating an RCP | Allow effect, specific principal, NotAction, or "Action": "*" | Use Deny, "Principal": "*", name services |
Cross-account S3 PutObject succeeds but readers get AccessDenied | Object owned by writer; or KMS key policy does not allow reader | Set Object Ownership to bucket owner enforced; grant kms:Decrypt in key policy |
| SNS cannot deliver to SQS | Queue policy missing or wrong aws:SourceArn | Allow sns.amazonaws.com with aws:SourceArn = topic ARN |
ConstraintViolationException attaching an SCP | 10 SCPs already attached to the target | Merge policies; quotas are hard limits |
Cost and cleanup
IAM, policy simulation, AWS Organizations, SCPs and RCPs have no charge. The lab creates only IAM objects. Delete them anyway: unused roles and policies are attack surface and clutter your audit evidence.
ACCOUNT=$(aws sts get-caller-identity --query Account --output text --profile learn-sandbox)
# Remove test roles created by the developer.
aws iam detach-role-policy --role-name hl-m05-try2 \
--policy-arn arn:aws:iam::aws:policy/AdministratorAccess --profile learn-sandbox
aws iam delete-role --role-name hl-m05-try2 --profile learn-sandbox
# Remove the developer role.
aws iam detach-role-policy --role-name hl-m05-developer \
--policy-arn "arn:aws:iam::$ACCOUNT:policy/hl-m05-developer-policy" --profile learn-sandbox
aws iam delete-role-permissions-boundary --role-name hl-m05-developer --profile learn-sandbox
aws iam delete-role --role-name hl-m05-developer --profile learn-sandbox
# Delete the policies.
for p in hl-m05-developer-policy hl-m05-developer-boundary hl-m05-app-boundary; do
aws iam delete-policy --policy-arn "arn:aws:iam::$ACCOUNT:policy/$p" --profile learn-sandbox
done
# If you attached an RCP to the Sandbox OU, detach and delete it (management account).
# aws organizations detach-policy --policy-id p-examplercp1 --target-id ou-abcd-sandbox1 --profile learn-mgmt
# aws organizations delete-policy --policy-id p-examplercp1 --profile learn-mgmt
# Confirm nothing tagged for this lab remains.
aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=cea-lab \
--query 'ResourceTagMappingList[].ResourceARN' --profile learn-sandbox
aws iam list-roles --path-prefix /hl-m05-app/ --profile learn-sandboxExercises
- 🟢 Guided: Complete Lab 5.2 above. Record the result of each test and which policy statement caused it.
- 🟡 Challenge: Extend the developer policy so developers may also create inline policies on their app roles, and may create roles for ECS tasks (
ecs-tasks.amazonaws.com) as well as Lambda — without opening any new escalation path. Prove it with the C# simulator and two real calls. - 🔴 Live problem: A ticket arrives: "Since this morning the data-platform team's nightly Glue job in
analytics-prodfails withAccessDeniedwriting tos3://hl-reporting-exports. Nothing changed on our side." Yesterday the security team attached a new RCP to the Workloads OU. Investigate (using CloudTrail and the policies), decide whether this is a bug in the RCP or a real policy violation, and propose a fix that keeps the perimeter intact.
Assignment
Create a guardrails/ folder in your portfolio repository with: hl-scp-baseline.json, hl-rcp-perimeter.json, the app and developer boundary policies, the C# boundary simulator, and a one-page README.md that lists every escalation path you closed and how. Add a GitHub Actions job that runs aws accessanalyzer validate-policy on each JSON file (with OIDC credentials — see Federation and segregation of duties).
Solutions
Expected results: Test 1 AccessDenied — no statement allows CreateRole without iam:PermissionsBoundary equal to the app boundary. Test 2 succeeds — CreateAndChangeAppRolesOnlyWithBoundary matches the path and the condition. Test 3 succeeds — the role already carries the app boundary, so the condition on AttachRolePolicy is met; this is intended, because the boundary caps the result. The simulator then shows sqs:SendMessage allowed (in both admin policy and boundary), s3:ListAllMyBuckets implicitly denied (not in the boundary), iam:CreateUser explicitly denied (boundary Deny iam:*). Test 4 both calls AccessDenied with explicit deny — DenyBoundaryRemoval and DenyEditingBoundaryPolicies. Why it matters: the boundary turns "whatever the developer attaches" into "at most what the platform team approved".
PutRolePolicy and DeleteRolePolicy are already in the condition-protected statement, so inline policies are allowed only on roles carrying the boundary — and inline policies are capped by it too. For ECS, change the PassRole condition to "StringEquals": { "iam:PassedToService": ["lambda.amazonaws.com", "ecs-tasks.amazonaws.com"] }. Do not add iam:UpdateAssumeRolePolicy on non-app roles, and keep the path restriction, otherwise a developer could edit the trust policy of a privileged role to trust themselves. Add simulator cases for iam:PassRole with iam:PassedToService context entries (ContextEntries in SimulateCustomPolicyRequest) for ec2.amazonaws.com (expect implicitDeny).
- In the analytics-prod account, search CloudTrail for
errorCode = AccessDeniedonPutObjectaround the job's run time; the error message names the policy type ("explicit deny in a resource control policy"). 2. Note the RCP applies to the bucket's account, not the caller's. Check which account ownshl-reporting-exports— it might be outside the organisation (a legacy account or a vendor), or the caller may be a Glue service call. 3. If the bucket is in an external vendor account, the RCP is not involved (RCPs only protect member-account resources) — look instead at a resource-perimeter SCP. If the caller is an AWS service acting through a forward-access session, check that the RCP usesaws:PrincipalIsAWSService/aws:ViaAWSServicecorrectly. 4. Fix: if the vendor bucket is legitimate, add a documentedaws:ResourceAccountexception to the resource-perimeter SCP, scoped to that bucket and approved by risk; otherwise migrate the export to an organisation-owned bucket. Never remove the perimeter to fix one job.
Knowledge check
Answer: The member-account root user cannot — SCPs apply to all IAM users and roles in member accounts, including the root user. A principal in the management account can, because SCPs never affect the management account.
Answer: SCPs only constrain principals that belong to the accounts they are attached to. A principal in an external account is outside your SCPs. RCPs constrain the resources in your member accounts, so they apply to any caller, including external ones.
Answer: Removing the boundary (iam:DeleteRolePermissionsBoundary), replacing it with a weaker one (iam:PutRolePermissionsBoundary without the condition), editing the boundary policy (iam:CreatePolicyVersion, iam:SetDefaultPolicyVersion, iam:DeletePolicyVersion), and passing privileged roles (iam:PassRole without path/service restrictions). Also limit role-management actions to a path so the developer cannot modify their own role.
Answer: Identity-based policies and resource-based policies (including role trust policies and KMS key policies). Permission boundaries, SCPs, RCPs and session policies only limit. ACLs also grant, but banks disable them for S3.
Answer: (1) The role's identity policy in A must allow s3:GetObject on the object and kms:Decrypt on B's key. (2) The bucket policy in B must allow A's role s3:GetObject. (3) The KMS key policy in B must allow A's role (or A's account, with A's identity policy delegating) kms:Decrypt. (4) No SCP on A, RCP on B, boundary or session policy may block it.
Interview questions
- "How would you let 40 product teams create their own IAM roles without giving them a path to admin?" — Permission boundaries made mandatory with the
iam:PermissionsBoundarycondition, delegation limited to a role path,PassRolerestricted by path and service, explicit denies on boundary removal and edits, delivered through a permission set and enforced in CDK with an aspect. Plus Access Analyzer validation in CI. - "What is the difference between an SCP and an RCP?" — SCPs cap what principals in my member accounts can do anywhere; RCPs cap what anyone can do to resources in my member accounts. Together they form the identity and resource sides of a data perimeter. Neither grants anything and neither affects the management account or service-linked roles.
- "Explain a data perimeter." — Three checks: only trusted identities access my resources (RCP +
aws:PrincipalOrgID), my identities access only trusted resources (SCP +aws:ResourceOrgID), and access only from expected networks (aws:SourceVpce,aws:SourceIp). Exceptions for AWS services acting on my behalf useaws:PrincipalIsAWSServiceandaws:ViaAWSService. - "A colleague wants to attach a new SCP at the organisation root today. What do you say?" — Test it first in a sandbox OU, check service-last-accessed data and CloudTrail
AccessDeniedevents, roll out OU by OU, keep a break-glass exception, and have a rollback plan.
Certification practice
A bank wants application developers to create IAM roles for their Lambda functions without being able to grant themselves more permissions than the security team allows. Which solution meets the requirement with the LEAST operational overhead?
A. Require developers to raise a ticket; the security team creates every role.
B. Give developers iam:CreateRole and use AWS Config to delete roles that have AdministratorAccess attached.
C. Create a permissions boundary policy. Allow developers iam:CreateRole and related actions only when the iam:PermissionsBoundary condition key equals that policy's ARN, and deny deleting or modifying the boundary.
D. Attach an SCP that denies iam:AttachRolePolicy for the AdministratorAccess policy.
Answer: C. It is preventive and self-service. A works but has high operational overhead. B is detective and leaves a window of exposure; an over-privileged role can be created with policies other than AdministratorAccess. D blocks one managed policy only — the developer could write an inline policy with Action: *.
A financial services company must ensure that no principal outside its AWS organisation can access objects in any S3 bucket in its member accounts, even if a bucket policy is misconfigured. AWS services must still be able to deliver logs to the buckets. What should the security engineer do?
A. Attach an SCP that denies s3:* when aws:PrincipalOrgID is not the organisation ID.
B. Attach an RCP that denies s3:* for "Principal": "*" when aws:PrincipalOrgID is not the organisation ID, with a BoolIfExists condition on aws:PrincipalIsAWSService = false.
C. Enable S3 Block Public Access at the account level in every account.
D. Use IAM Access Analyzer to alert on buckets shared outside the organisation.
Answer: B. RCPs apply to all callers of resources in member accounts, including external principals, and the service-principal exception keeps log delivery working. A is wrong because SCPs do not affect principals outside the organisation. C blocks public access but not access granted to specific external accounts. D detects but does not prevent.
An SNS topic in account A must deliver messages to an SQS queue in account B. Messages are not arriving. The SNS subscription is confirmed. What is the MOST likely missing configuration?
A. An IAM role in account B that SNS can assume.
B. An SQS queue policy in account B that allows sns.amazonaws.com to call sqs:SendMessage with aws:SourceArn equal to the topic ARN.
C. A VPC endpoint for SQS in account A.
D. An SCP in account A that allows sqs:SendMessage.
Answer: B. SNS delivers to SQS using the queue's resource policy. A is not how SNS-to-SQS delivery works. C is unrelated to service-to-service delivery. D is wrong because SCPs never grant permissions.
A security engineer attaches an SCP that denies cloudtrail:StopLogging to the organisation root. Later, an administrator stops the organisation trail successfully. What is the MOST likely explanation?
A. The SCP needs 24 hours to propagate.
B. The administrator used a role in the management account, which SCPs do not affect.
C. The administrator had AdministratorAccess, which overrides SCPs.
D. CloudTrail is a global service and is exempt from SCPs.
Answer: B. SCPs never restrict principals in the management account; the organisation trail is typically managed from there. A is false; SCP changes are effective quickly. C is false — SCPs cap even administrators in member accounts. D is false.
Completion checklist
- I can explain which policy types grant and which only cap, in two sentences
- I completed Lab 5.2 and recorded the reason for each allow/deny
- I can list who SCPs and RCPs do not affect
- I wrote an identity-perimeter RCP and know why
aws:PrincipalIsAWSServiceis needed - I can list every policy needed for a cross-account SSE-KMS read
- I ran the cleanup and confirmed no
hl-m05-*roles or policies remain
Key takeaways
- Boundaries, SCPs, RCPs and session policies never grant; they only cap. An action needs a grant and must pass every cap.
- A permission boundary only delivers safe delegation when it is mandatory (
iam:PermissionsBoundarycondition) and tamper-proof (deny removal and edits). - SCPs cap principals in member accounts (including their root users); RCPs cap access to resources in member accounts from anyone. Neither touches the management account or service-linked roles.
- Cross-account access needs an allow on both sides; KMS key policies are always part of the decision for encrypted data.
- A data perimeter combines identity (
aws:PrincipalOrgID), resource (aws:ResourceOrgID) and network (aws:SourceVpce) controls — roll guardrails out OU by OU, never root-first.
Further reading
- Permissions boundaries for IAM entities — IAM User Guide
- Service control policies (SCPs) and SCP syntax
- Resource control policies (RCPs) and RCP syntax
- Declarative policies
- Quotas for AWS Organizations
- AWS::Organizations::Policy (CloudFormation)
- Data perimeter policy examples (aws-samples, GitHub)
- Service control policy examples (aws-samples, GitHub)
Independent learning resource — not affiliated with, endorsed or sponsored by Amazon Web Services. AWS and related marks are trademarks of Amazon.com, Inc. or its affiliates. All banking data in examples is fictional. Sample architectures are for learning and are not automatically compliant with GDPR, PCI DSS or any banking regulation.
IAM Identity Center, MFA and temporary credentials
Give people short-lived, MFA-protected access through IAM Identity Center permission sets, and make applications assume roles safely with STS — external IDs, source identity, session tags and the one-hour role-chaining limit — from the CLI and from C#.
Federation and segregation of duties
Connect Microsoft Entra ID or Active Directory to IAM Identity Center, federate CI/CD pipelines with OIDC, use attributes for access control, and design roles that separate building, approving, deploying and auditing.