aws / aws/aws-cdk

(core): Property value of a resource inside a CDK Stage contains the CDK Pipelines pipeline construct ID

Open
#16,830 11 comments 32 reactions 0 assignees View on GitHub
@aws-cdk/core bug effort/medium p1
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### What is the problem?

Per @rix0rrr, logical IDs generated by the AWS CDK should be based on the construct path to the nearest containing stack. Currently, this logic doesn't hold for resource property names auto-generated by the AWS CDK for resources that MUST have a name in CloudFormation.

Consider the following construct tree and resources: `App` -> `Pipeline stack (CDK Pipelines)` -> `Prod stage` -> `Stateless stack`-> `Amazon CodeGuru Profiler profiling group`. The current implementation adds the pipeline stack construct ID as a prefix for the profiling group name. That creates an unneeded dependency between pipeline construct ID and production resources. Changing pipeline construct ID can affect production resources (e.g. replacement).

### Reproduction Steps

```bash
git clone https://github.com/alexpulver/usermanagement-backend
cd usermanagement-backend/
export AWS_ACCESS_KEY_ID="***"
export AWS_SECRET_ACCESS_KEY="***"
export AWS_SESSION_TOKEN="***"
python3.7 -m venv .venv
source .venv/bin/activate
./scripts/install-deps.sh
npx cdk ls "**"
grep ProfilingGroupName cdk.out/assembly-UserManagementBackend-Pipeline-UserManagementBackend-Prod/UserManagementBackendPipelineUserManagementBackendProdStateless5E346530.template.json
```

The Amazon CodeGuru Profiler profiling group name below contains `UserManagementBackendPipeline` string, that is generated from the construct ID of the pipeline stack:
```
"ProfilingGroupName": "UserManagementBackendPipelineUserManagementBackendProdStatelessAPILambdaFunctionProfilingGroup9415F6C1",
```

### What did you expect to happen?

I would expect that profiling group name will start from the construct ID of the nearest containing stack:
```
"ProfilingGroupName": "UserManagementBackendProdStatelessAPILambdaFunctionProfilingGroup9415F6C1",
```

### What actually happened?

The Amazon CodeGuru Profiler profiling group name below contains `UserManagementBackendPipeline` string, that is generated from the construct ID of the pipeline stack:
```
"ProfilingGroupName": "UserManagementBackendPipelineUserManagementBackendProdStatelessAPILambdaFunctionProfilingGroup9415F6C1",
```

### CDK CLI Version

1.117.0 (build 0047c98)

### Framework Version

1.117.0

### Node.js Version

v14.16.1

### OS

macOS Catalina 10.15.7

### Language

Python

### Language Version

Python (3.7.9)

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the listed usermanagement-backend commands, especially `npx cdk ls "**"` and the grep of the synthesized template. Trace how CDK core generates `ProfilingGroupName` for the nested Stage and Stateless stack. Done means the generated name omits `UserManagementBackendPipeline` and begins with the nearest containing stack's construct-derived name.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.