Sub topic 13
Beyond SCPs: RCPs, Tag, Backup and Declarative Policies
This chapter assumes you can write IAM JSON policies. It also assumes you know how SCPs are inherited and evaluated, and that you can run aws organizations commands from the management account.
SCPs limit what principals in your accounts can do. AWS Organizations has other policy types for other jobs. Some limit access to resources, some standardize tags, some define backups, and some fix service configuration. All of them attach to the root, an OU or an account, as SCPs do.
The policy types at a glance
| Policy type | What it controls | Mechanism | Inheritance |
|---|---|---|---|
| SCP | Maximum permissions of principals in member accounts | Permission boundary | Intersection down the tree |
| RCP | Maximum permissions on resources in member accounts | Permission boundary | Intersection down the tree |
| Tag policy | Tag keys and allowed values | Compliance reporting, optional enforcement | Merged into an effective policy |
| Backup policy | AWS Backup plans | Plans deployed to accounts | Merged into an effective policy |
| Declarative policy | Baseline configuration of a service | Enforced at the service, independent of API calls | Merged into an effective policy |
The first two are authorization policies. They use IAM-style Effect, Action and Condition. The last three are management policies. They use a different JSON syntax with inheritance operators.
Enabling a policy type
Each type must be enabled on the root before you can attach it. SCPs are enabled by default in an organization with all features. The others are not.
ROOT_ID=$(aws organizations list-roots --query 'Roots[0].Id' --output text)
aws organizations enable-policy-type \
--root-id "$ROOT_ID" \
--policy-type RESOURCE_CONTROL_POLICY
aws organizations enable-policy-type \
--root-id "$ROOT_ID" \
--policy-type TAG_POLICY
aws organizations enable-policy-type \
--root-id "$ROOT_ID" \
--policy-type BACKUP_POLICY
aws organizations enable-policy-type \
--root-id "$ROOT_ID" \
--policy-type DECLARATIVE_POLICY_EC2Resource control policies
An SCP answers the question "what can my principals do?" It says nothing about who can reach your resources. If a developer attaches a bucket policy that allows an outside account, no SCP stops that outside account from reading the bucket, because SCPs only apply to principals in your organization.
A resource control policy (RCP) closes that gap. It sets the maximum permissions on resources in member accounts, whoever the caller is. It applies to the supported services only, which include Amazon S3, AWS STS, AWS KMS, Amazon SQS and AWS Secrets Manager. Check the current list in the AWS documentation before you rely on a service.
The following RCP is a common data-perimeter control. It denies S3 access from any principal outside your organization:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "EnforceOrgIdentities",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "*",
"Condition": {
"StringNotEqualsIfExists": {
"aws:PrincipalOrgID": "o-exampleorgid"
},
"BoolIfExists": {
"aws:PrincipalIsAWSService": "false"
}
}
}
]
}Principalmust be"*". The condition does the narrowing.- The
aws:PrincipalIsAWSServicecondition exempts AWS services acting on your behalf, such as CloudTrail delivering logs to a bucket. - Public, anonymous requests have no
aws:PrincipalOrgID. TheIfExistsoperator makes them match the deny, which is what you want.
Create and attach it as you would an SCP, with a different --type:
aws organizations create-policy \
--name EnforceOrgIdentities \
--description "Deny S3 access from outside the organization" \
--type RESOURCE_CONTROL_POLICY \
--content file://enforce-org-identities.json
aws organizations attach-policy \
--policy-id p-examplepolicyid222 \
--target-id ou-examplerootid111-exampleouid111RCPs have limits that SCPs share. They do not apply to the management account, and they do not grant anything. A request must still be allowed by the resource policy or identity policy.
How the authorization policies combine
When a principal in one account calls a resource in another, several layers apply. A request succeeds only if no layer denies it and the usual IAM rules allow it.
Use SCPs to restrict your own principals, and RCPs to restrict who can touch your resources. They complement each other. The usual data-perimeter pattern uses both.
Tag policies
A tag policy defines which tag keys and values are correct. Without one, CostCenter, costcenter and Cost-Center all appear in your billing data and split your cost allocation reports. A tag policy fixes the key's capitalization and lists the allowed values:
{
"tags": {
"CostCenter": {
"tag_key": { "@@assign": "CostCenter" },
"tag_value": { "@@assign": ["1001", "1002", "1003"] },
"enforced_for": { "@@assign": ["ec2:instance"] }
}
}
}By default, tag policies only report. You see non-compliant resources in the Tag Policies console view or in Resource Groups, and nothing is blocked. Adding enforced_for for a resource type makes non-compliant tagging operations on those resources fail. A policy only evaluates tags that exist. A resource with no tags at all is not reported as non-compliant. If you need to require a tag, pair the policy with an SCP that denies resource creation when aws:RequestTag/CostCenter is missing.
Backup policies
A backup policy defines AWS Backup plans once and deploys them to every account below the target. The policy names the schedule, the Regions, the retention and the target vault. It selects resources by tag, for example everything tagged Backup=daily. The accounts must have an IAM role and a vault that the policy references. Create those with your baseline automation, since the policy does not create them. A backup policy gives you a consistent minimum. Teams can still add plans of their own in their accounts.
Declarative policies
Declarative policies set the desired state of a service's configuration, such as EC2. The service enforces them on its own, so they hold even when AWS adds new API actions. An SCP that blocks ec2:EnableImageBlockPublicAccess-style actions has to name every route to a result. A declarative policy states the result:
{
"ec2_attributes": {
"image_block_public_access": {
"state": { "@@assign": "block_new_sharing" }
},
"serial_console_access": {
"status": { "@@assign": "disabled" }
}
}
}With this policy, no account in scope can share new AMIs publicly or enable the EC2 serial console, even a user with administrator permissions. You can set a custom error message so that blocked users see your internal guidance.
Inheritance for management policies
SCPs and RCPs intersect as you go down the tree. Tag, backup and declarative policies are merged instead. Each level's policy is combined with its parent's, and operators control the result:
@@assignoverwrites the inherited value.@@appendadds values to the inherited list.@@removeremoves values from the inherited list.@@operators_allowed_for_child_policieslimits which operators a child policy may use, so a parent can lock a setting.
To see what actually applies to an account, ask for the effective policy:
aws organizations describe-effective-policy \
--policy-type TAG_POLICY \
--target-id 111122223333Common errors
- Attaching a policy of a type that is not enabled on the root. The call fails until you run
enable-policy-type. - Expecting an RCP to cover every service. Unsupported services ignore it.
- Writing an RCP statement with a specific principal instead of
"*". - Assuming a tag policy blocks untagged resources.
- Testing only in the management account. SCPs and RCPs do not apply there, so a test there proves nothing.
Exercise
A bucket policy in a member account allows s3:GetObject to an account outside your organization. Your SCPs deny nothing relevant. Which policy type can block that access for every account in the organization, and why can't an SCP do it?
Show answer
A resource control policy (RCP) can block it. SCPs only limit principals inside your organization, so they never apply to a caller from an outside account. An RCP applies to the resource, so it can deny S3 requests where aws:PrincipalOrgID is not your organization (exempting AWS service principals).
Exercise
A tag policy lists allowed values for CostCenter, but an engineer launches an EC2 instance with no tags and the launch succeeds. Name two reasons this is expected, and one way to require the tag.
Show answer
Tag policies check only the tags that exist, so a missing tag is not a violation. Also, a tag policy blocks only when enforced_for covers the resource type, and even then it blocks wrong values, not missing ones. To require the tag, add an SCP that denies ec2:RunInstances when the aws:RequestTag/CostCenter condition key is absent.