How do I assign resources to a Backup plan?

2 minute read
0

I want to specify resources to a Backup plan in AWS Backup.

Resolution

To assign resources to a Backup plan, use resource assignment in AWS Backup.

You can create a resource assignment using the AWS Backup console or programmatically using the AWS Command Line Interface (AWS CLI).

Important: You can assign resources to a Backup plan only after the Backup plan is created. All rules in your Backup plan apply to your resource assignment.

Examples

The following are examples of how a Backup selection JSON is used for Backup selections when using the AWS CLI. You can use these examples with the create-backup-selection API.

Note: It's a best practice to specify the Conditions, ListofTags, NotResources, and Resources. If these parameters aren't specified, then Backup selects all supported and opted-in storage resources.

Example 1

The following example backs up Amazon Elastic Block Store (Amazon EBS) volumes that are tagged with backup:yes and owner:example.

Note: In this example, Resources and Conditions are combined using the boolean value AND.

{
    "BackupSelection": {
        "SelectionName": "Example-1",
        "IamRoleArn": "arn:aws:iam::111122223333:role/service-role/AWSBackupDefaultServiceRole",
        "Resources": ["arn:aws:ec2:\*:\*:volume/\*"],
        "ListOfTags": [],
        "NotResources": [],
        "Conditions": {
            "StringEquals": [
                {"ConditionKey": "aws:ResourceTag/backup", "ConditionValue": "yes"},
                {"ConditionKey": "aws:ResourceTag/owner", "ConditionValue": "example"},
            ],
            "StringNotEquals": [],
            "StringLike": [],
            "StringNotLike": [],
        },
    }
}

Example 2

The following example backs up all Amazon EBS volumes or all resources that are tagged with backup:yes.

Note: In this example, Resources and ListOfTags are combined using the boolean value OR.

{
    "BackupSelection": {
        "SelectionName": "Example-2",
        "IamRoleArn": "arn:aws:iam::111122223333:role/service-role/AWSBackupDefaultServiceRole",
        "Resources": ["arn:aws:ec2:\*:\*:volume/\*"],
        "ListOfTags": [
            {
                "ConditionType": "STRINGEQUALS",
                "ConditionKey": "backup",
                "ConditionValue": "yes",
            }
        ],
        "NotResources": [],
        "Conditions": {
            "StringEquals": [],
            "StringNotEquals": [],
            "StringLike": [],
            "StringNotLike": [],
        },
    }
}

Example 3

The following example backs up Amazon EBS volumes or Amazon Relational Database Service (Amazon RDS) resources that are tagged with backup:true and owner:test.

Note: In this example, the parameters in Resources are combined using the boolean OR. The parameters in Conditions are combined using the boolean AND.

{
    "BackupSelection": {
        "SelectionName": "Example-3",
        "IamRoleArn": "arn:aws:iam::111122223333:role/service-role/AWSBackupDefaultServiceRole",
        "Resources": ["arn:aws:ec2:\*:\*:volume/\*", "arn:aws:rds:\*:\*:db:\*"],
        "ListOfTags": [],
        "NotResources": [],
        "Conditions": {
            "StringEquals": [
                {"ConditionKey": "aws:ResourceTag/backup", "ConditionValue": "true"},
                {"ConditionKey": "aws:ResourceTag/owner", "ConditionValue": "test"},
            ]
        },
        "StringNotEquals": [],
        "StringLike": [],
        "StringNotLike": [],
    }
}

Related information

Assigning resources using AWS CloudFormation

Quotas on resource assignment

AWS OFFICIAL
AWS OFFICIALUpdated 10 months ago