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 |
This issue description was created using Claude code
🐛
aws-backup:BackupSelectionusesListOfTagsinstead ofConditions, breaking AND logic and limiting tag operationsLabels: bug, needs-triage
Describe the bug
BackupSelectiongeneratesListOfTagsin CloudFormation instead of the newerConditionsproperty. This has two consequences:ListOfTagsuses OR across conditions;Conditionsuses AND. MultiplefromTag()calls silently back up more resources than intended.TagOperationonly exposesSTRING_EQUALSand a non-functionalDUMMY = 'dummy'placeholder.ConditionssupportsStringLike,StringNotEquals, andStringNotLike— none of which are accessible.Expected Behavior
Current Behavior
Reproduction Steps
cdk synthproducesListOfTags(OR). Both conditions must be met — AND is required.Possible Solution
selection.ts: replacelistOfTagswithconditions, grouping by operation type intoStringEquals/StringLike/StringNotEquals/StringNotLike.resource.ts: replaceDUMMY = 'dummy'with the three missingTagOperationmembers.conditionsis typedanyinCfnBackupSelection.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