Skip to content

aws-backup: BackupSelection uses ListOfTags (OR logic), missing support for StringLike/StringNotEquals/StringNotLike #37771

@emfrab

Description

@emfrab

This issue description was created using Claude code

🐛 aws-backup: BackupSelection uses ListOfTags instead of Conditions, breaking AND logic and limiting tag operations

Labels: bug, needs-triage


Describe the bug

BackupSelection generates ListOfTags in CloudFormation instead of the newer Conditions property. This has two consequences:

  • Wrong logic: ListOfTags uses OR across conditions; Conditions uses AND. Multiple fromTag() calls silently back up more resources than intended.
  • Limited operations: TagOperation only exposes STRING_EQUALS and a non-functional DUMMY = 'dummy' placeholder. Conditions supports StringLike, StringNotEquals, and StringNotLike — none of which are accessible.

Expected Behavior

"BackupSelection": {
  "Conditions": {
    "StringEquals": [
      { "ConditionKey": "aws:ResourceTag/Environment", "ConditionValue": "prod" },
      { "ConditionKey": "aws:ResourceTag/Backup", "ConditionValue": "enabled" }
    ]
  }
}

Current Behavior

"BackupSelection": {
  "ListOfTags": [
    { "ConditionKey": "aws:ResourceTag/Environment", "ConditionType": "STRINGEQUALS", "ConditionValue": "prod" },
    { "ConditionKey": "aws:ResourceTag/Backup", "ConditionType": "STRINGEQUALS", "ConditionValue": "enabled" }
  ]
}

Reproduction Steps

new BackupSelection(stack, 'Selection', {
  backupPlan: plan,
  resources: [
    BackupResource.fromTag('aws:ResourceTag/Environment', 'prod'),
    BackupResource.fromTag('aws:ResourceTag/Backup', 'enabled'),
  ],
});

cdk synth produces ListOfTags (OR). Both conditions must be met — AND is required.

Possible Solution

  • In selection.ts: replace listOfTags with conditions, grouping by operation type into StringEquals/StringLike/StringNotEquals/StringNotLike.
  • In resource.ts: replace DUMMY = 'dummy' with the three missing TagOperation members.
  • Note: conditions is typed any in CfnBackupSelection.BackupSelectionResourceTypeProperty, so keys must be constructed in PascalCase explicitly (no camelCase→PascalCase transform is applied).

This is a behavior change (OR → AND) but is the correct semantic for tag-based selection and matches what the AWS console produces.

Environment

aws-cdk-lib 2.250.0
CDK CLI 2.1112.0 (build 48e9b5d)
Node.js v24.11.1
OS macOS
Language TypeScript

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-backupRelated AWS BackupbugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions