# BackupSelectionOptions

Options for a BackupSelection.

- Source: [`aws-backup/lib/selection.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-backup/lib/selection.ts#L19)
- Type last changed: v2.112.0 · 1 Dec 2023

## Example

```ts
declare const plan: backup.BackupPlan;
declare const vpc: ec2.Vpc;
const myTable = dynamodb.Table.fromTableName(this, 'Table', 'myTableName');
const myDatabaseInstance = new rds.DatabaseInstance(this, 'DatabaseInstance', {
  engine: rds.DatabaseInstanceEngine.mysql({ version: rds.MysqlEngineVersion.VER_8_0_26 }),
  vpc,
});
const myDatabaseCluster = new rds.DatabaseCluster(this, 'DatabaseCluster', {
  engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_2_08_1 }),
  credentials: rds.Credentials.fromGeneratedSecret('clusteradmin'),
  instanceProps: {
    vpc,
  },
});
const myServerlessCluster = new rds.ServerlessCluster(this, 'ServerlessCluster', {
  engine: rds.DatabaseClusterEngine.AURORA_POSTGRESQL,
  parameterGroup: rds.ParameterGroup.fromParameterGroupName(this, 'ParameterGroup', 'default.aurora-postgresql11'),
  vpc,
});
const myCoolConstruct = new Construct(this, 'MyCoolConstruct');

plan.addSelection('Selection', {
  resources: [
    backup.BackupResource.fromDynamoDbTable(myTable), // A DynamoDB table
    backup.BackupResource.fromRdsDatabaseInstance(myDatabaseInstance), // A RDS instance
    backup.BackupResource.fromRdsDatabaseCluster(myDatabaseCluster), // A RDS database cluster
    backup.BackupResource.fromRdsServerlessCluster(myServerlessCluster), // An Aurora Serverless cluster
    backup.BackupResource.fromTag('stage', 'prod'), // All resources that are tagged stage=prod in the region/account
    backup.BackupResource.fromConstruct(myCoolConstruct), // All backupable resources in `myCoolConstruct`
  ]
})
```

## Properties

- `allowRestores`: boolean = false — Whether to automatically give restores permissions to the role that AWS Backup uses.

  If `true`, the `AWSBackupServiceRolePolicyForRestores` managed
  policy will be attached to the role.

- `backupSelectionName`: string — The name for this selection.

  **Default:** a CDK generated name

- `disableDefaultBackupPolicy`: boolean = false — Whether to disable automatically assigning default backup permissions to the role that AWS Backup uses.

  If `false`, the `AWSBackupServiceRolePolicyForBackup` managed policy will be
  attached to the role.

- `resources`: [BackupResource](/cdk/api/v2/docs/aws-cdk-lib.aws_backup.BackupResource.html)[] (required) — The resources to backup.

  Use the helper static methods defined on `BackupResource`.

- `role`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The role that AWS Backup uses to authenticate when backuping or restoring the resources.

  **Default:** a new role will be created

  The `AWSBackupServiceRolePolicyForBackup` managed policy
  will be attached to this role unless `disableDefaultBackupPolicy`
  is set to `true`.
