Sub topic 8
Assigning resources with tags or ARNs
This chapter assumes you know how to create a backup plan and can tag AWS resources. A plan only defines when and how to back up. A resource assignment (also called a backup selection) tells the plan what to back up. Until you create one, the plan runs but protects nothing.
How an assignment works
An assignment belongs to one plan and holds two things:
- An IAM role that AWS Backup assumes to reach the resources.
- A way to pick resources: a list of ARNs, a list of tags, or both.
When a rule fires, AWS Backup evaluates the selection and starts one backup job per matching resource.
Selecting by tag
Tag selection scales best. Anyone who tags a new resource backup=daily brings it under the plan, and you don't have to edit the plan. This is the selection file from the plan you created earlier:
{
"SelectionName": "tagged-backup-daily",
"IAMRoleArn": "arn:aws:iam::123456789012:role/service-role/AWSBackupDefaultServiceRole",
"ListOfTags": [
{
"ConditionType": "STRINGEQUALS",
"ConditionKey": "backup",
"ConditionValue": "daily"
}
]
}Attach it with the plan ID returned when you created the plan:
aws backup create-backup-plan \
--backup-plan file://plan.json
aws backup create-backup-selection \
--backup-plan-id <backup-plan-id> \
--backup-selection file://selection.jsonEvery supported resource in the Region with the tag backup=daily is now protected.
Selecting by ARN
Use the Resources list when you want specific resources and don't want to depend on tagging discipline. Each entry is a full ARN, and a wildcard such as arn:aws:ec2:*:*:volume/* selects every resource of that type. ARN selection suits a small, stable set of critical resources.
Common errors
- Tag typos. Tag keys and values are case-sensitive.
Backup=Dailydoes not matchbackup=daily, so the resource is silently skipped. - Missing role permissions. If the role can't back up a resource type, the job fails. The default service role covers the standard managed policies, but encrypted resources also need access to the KMS key.
- Wrong Region. Assignments apply to the Region of the plan. A tagged resource in another Region is not protected.
- Overlapping plans. A resource that matches two plans is backed up by both, which doubles cost and recovery points.
- Unsupported resources. A tag on a resource type AWS Backup doesn't support has no effect.
Verify the assignment
List the selections on a plan, then check the backup jobs after the next scheduled run:
aws backup list-backup-selections \
--backup-plan-id <backup-plan-id>
aws backup list-backup-jobs \
--by-backup-vault-name app-vaultExercise
A new RDS instance is tagged Backup=daily, but the selection uses the condition key backup with value daily and the instance never appears in backup jobs. What is the likely cause, and how do you fix it?
Show answer
Tag keys and values are case-sensitive, so Backup=daily does not match the key backup. Change the tag on the instance to backup=daily, or add a matching condition to the selection. The instance will be included at the next scheduled backup.