-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
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.jsonThe 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