Skip to content

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

@alexpulver

Description

@alexpulver

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/coreRelated to core CDK functionalitybugThis issue is a bug.effort/mediumMedium work item – several days of effortp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions