Open lukehoban opened 1 year ago
Yes, AWS CDK will always have a name associated with a construct, and the name must be unique at the specific construct/component level. The global name associated with the resource is built from the hierarchy of resource names, with some characters stripped out.
That model can also cause very long names. This tends to become more of a problem with CDK pipelines, since the pipeline itself gets encoded into the name hierarchy and sometimes things hit a 128 character limit and will not work (with CloudFormation). However, if it works to use pretty much the same model, then it will at least be predictable in terms of names compared to AWS CDK (CloudFormation flavour).
This one is going to be tricky to fix generally. We are using the CloudFormation logicalId which can be up to 128 characters. CloudFormation will then generate a unique resource name using the Stack name and the resource name, but will make sure the generated name fits within any unique service limits.
So for example if I have a stack with the name AwsCdkTestAppStack
and a LB with the logicalId myapplicationloadbalancerwithalongname802BEFCA
, I might end up with a resource name of AwsCdk-myapp-ed0Q19JSgqxi
I can think of a couple of options
Let the user override the CloudFormation logicalId
(lb.node.defaultChild as CfnResource).overrideLogicalId('shortername');
Update the aws-native
autonaming implementation to modify the names to be within the max characters rather than throw an error
pulumi-cdk
could process the schema similar to autonaming
and modify the logicalId if it is too long.
Question from Community Slack:
I suspect that the issue is that we should be passing name through explicitly in the mapping linked below if provided (which it will always be I believe?) so that Pulumi doesn't apply it's own autonaming here. If you open an issue on this - we can look into whether that is indeed the right resolution. https://github.com/pulumi/pulumi-cdk/blob/342f7d5bbbc0d272c7e1616ae108b04c478add5d/src/aws-resource-mappings.ts#L210