aws / aws/aws-cdk

aws-backup: BackupPlanName is not unique, when generated (unlike the rest of the properties that are handled either by CDK or CFn)

Open
#38,318 4 comments 5 reactions 0 assignees View on GitHub
@aws-cdk/aws-backup bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

Greetings and salutations!

Source for bug: https://github.com/aws/aws-cdk/blob/8a62b589f662ead0d354ee519a04186f7f207193/packages/aws-cdk-lib/aws-backup/lib/plan.ts#L177

Unlike any other auto-gen props, this one copies the `id` when not supplied, causing collisions (a resource already using the name and therefore others not being created because of it).

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Last Known Working CDK Library Version

_No response_

### Expected Behavior

The generated name should be unique and in line with the service regEx.

### Current Behavior

Synth works when having two stacks in the same app, both having the same backupPlan `id`, but fails when deploying.

### Reproduction Steps

1. Define a stack that declares the backup plan
2. Skip the `backupPlanName` in the props provided to the constructor
3. Declare two instances of the same Stack type in the same App/ Account
4. Observe deployment failing

### Possible Solution

Use the logic available in https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/core/lib/private/unique-resource-name.ts

### Additional Information/Context

_No response_

### AWS CDK Library version (aws-cdk-lib)

2.257.0

### AWS CDK CLI version

2.1125.0

### Node.js Version

22.23.1

### OS

all

### Language

TypeScript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start in packages/aws-cdk-lib/aws-backup/lib/plan.ts at the BackupPlanName generation referenced in the report, then compare it with packages/aws-cdk-lib/core/lib/private/unique-resource-name.ts. Reproduce the two-stacks case with backupPlanName omitted and verify that synthesized names are unique and valid for the AWS Backup service regex.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.