Sub topic 15
Managing backups across an AWS Organization
This chapter assumes you can write a backup plan and selection for one account, as covered earlier in this tutorial. It also assumes you know the basics of AWS Organizations: the management account, organizational units (OUs), and service control policies. The chapter shows how to define a backup plan once and have AWS Backup apply it to every account in an OU.
Why use organization backup policies
Managing plans account by account does not scale. Teams drift apart on retention, some accounts have no plan at all, and an auditor has no single place to check. A backup policy is a policy type in AWS Organizations that holds a backup plan definition. You attach it to the organization root, an OU, or a single account. AWS Backup then creates the matching plan in each member account and keeps it in sync.
A backup policy gives you:
- One definition of schedule, retention, copy actions and resource selection.
- Automatic coverage of accounts that join an OU later.
- Plans in member accounts that local users cannot edit or delete. Only a policy change alters them.
How the pieces fit together
The diagram shows what happens after you attach a policy to an OU.
The policy does not create vaults or IAM roles. Each target account must already contain a vault and a role whose names match the policy. This is the most common reason a policy attaches cleanly but no backups run.
Prerequisites to enable
- Sign in to the management account of the organization.
- In the AWS Backup console settings, turn on cross-account management. This enables trusted access between AWS Backup and Organizations. It also enables the backup policy type.
- Confirm that the resource types you want to protect are opted in for AWS Backup in each member account and Region. Opt-in is an account-level setting that policies do not change.
If you work from the CLI, enable the policy type on the root. Look up the root ID first.
aws organizations list-roots
aws organizations enable-policy-type \
--root-id r-abcd \
--policy-type BACKUP_POLICYReplace r-abcd with the ID that list-roots returns.
Writing a backup policy
A backup policy is JSON. It has the same ideas as the plan and selection files you wrote earlier, but it uses snake_case keys. Each value is wrapped in an inheritance operator such as @@assign.
{
"plans": {
"OrgDaily": {
"regions": { "@@assign": ["us-east-1"] },
"rules": {
"Daily": {
"schedule_expression": { "@@assign": "cron(0 5 ? * * *)" },
"start_backup_window_minutes": { "@@assign": "60" },
"complete_backup_window_minutes": { "@@assign": "180" },
"target_backup_vault_name": { "@@assign": "app-vault" },
"lifecycle": {
"delete_after_days": { "@@assign": "35" }
}
}
},
"selections": {
"tags": {
"TaggedDaily": {
"iam_role_arn": {
"@@assign": "arn:aws:iam::$account:role/service-role/AWSBackupDefaultServiceRole"
},
"tag_key": { "@@assign": "backup" },
"tag_value": { "@@assign": ["daily"] }
}
}
},
"backup_plan_name": { "@@assign": "org-daily" }
}
}
}Points to notice:
regionslists where the plan runs. A policy only protects resources in the listed Regions.$accountis a variable. Organizations replaces it with each member account's ID, so one policy can name a role that exists in every account.- The selection here is tag-based: every supported resource tagged
backup=dailyis included. Tag selection keeps the policy independent of resource ARNs, which differ in every account. target_backup_vault_namemust match a vault that already exists in each account and Region listed.
Creating and attaching the policy
Save the JSON as org-daily.json, then create the policy and attach it to an OU.
aws organizations create-policy \
--name org-daily-backup \
--description "Daily backups with 35-day retention" \
--type BACKUP_POLICY \
--content file://org-daily.json
aws organizations attach-policy \
--policy-id p-examplepolicyid \
--target-id ou-abcd-12345678Use the policy ID returned by create-policy and the ID of your OU. To see what a specific account actually receives after inheritance, ask for its effective policy:
aws organizations describe-effective-policy \
--policy-type BACKUP_POLICY \
--target-id 123456789012Inheritance operators
Policies attached at several levels merge from the root downward. Operators control how a child policy changes what it inherits.
| Operator | Effect |
|---|---|
| `@@assign` | Sets the value, overwriting any inherited value. |
| `@@append` | Adds values to an inherited list, such as extra Regions or tag values. |
| `@@remove` | Removes specific values from an inherited list. |
A common pattern is to set a baseline plan at the root with @@assign. A child OU then uses @@append to add a Region or a tag value without redefining the plan. Check the result with describe-effective-policy before assuming the merge did what you intended.
Cross-account copies in a policy
Policies can also include copy actions, which makes them the usual way to build an isolated backup account. Add a copy_actions block to a rule. Its key is the ARN of the destination vault, and its value holds the copy's lifecycle.
"copy_actions": {
"arn:aws:backup:us-west-2:111122223333:backup-vault:central-vault": {
"target_backup_vault_arn": {
"@@assign": "arn:aws:backup:us-west-2:111122223333:backup-vault:central-vault"
},
"lifecycle": {
"delete_after_days": { "@@assign": "90" }
}
}
}The destination vault needs an access policy that allows copies in. The usual approach is to allow backup:CopyIntoBackupVault for principals in your organization using the aws:PrincipalOrgID condition key. Without that policy the copy jobs fail even though the source backup succeeds.
Delegated administration
Running everything from the management account is discouraged. You can register a member account as a delegated administrator for AWS Backup, and that account can then create and attach backup policies.
aws organizations register-delegated-administrator \
--account-id 111122223333 \
--service-principal backup.amazonaws.comEnable delegation in the AWS Backup settings as well, because registration alone does not grant policy-management permissions.
Common errors
- Policy attached, no plan appears. Cross-account management is not enabled, or the policy type is disabled on the root. Check both.
- Plan appears, jobs fail. The vault or the IAM role named in the policy is missing in that account. Create both, using identical names, in every target account, ideally with CloudFormation StackSets.
- Resources are skipped. The resource type is not opted in for that account, or the resource is in a Region absent from
regions. - You cannot edit the plan in a member account. This is intended. Change the policy in Organizations and wait for it to propagate.
- Tags match nothing. Tag keys and values are case sensitive. Compare the tag on the resource with
tag_keyandtag_valueexactly.
Exercise
You attach a backup policy to an OU. Ten minutes later, each member account shows a read-only plan, but every backup job fails with an error about the vault. Name two likely causes and one way to prevent the problem for future accounts.
Show answer
Likely causes: the vault named in targetbackupvault_name does not exist in that account and Region, or its name differs from the policy. A missing or differently named IAM role is a similar failure. Backup policies never create vaults or roles. To prevent this, deploy the vault and role to every account in the OU with an automated mechanism such as CloudFormation StackSets, so new accounts get them at creation.
Exercise
A root-level policy assigns Regions ["us-east-1"]. A child OU must also back up in eu-west-1 without redefining the plan. Which operator do you use in the child policy, and how do you confirm the result for one account?
Show answer
Use @@append on the regions list in the child OU's policy so eu-west-1 is added to the inherited list. Confirm with aws organizations describe-effective-policy --policy-type BACKUP_POLICY --target-id <account-id>, which shows the merged policy that account receives.