After upgrading to cdk v2, getting Stack name must be <= 128 characters
See original GitHub issueDescribe the bug
I have been using cdk with version 1.147.1, and my cdk apps were successfully deployed. After upgrading to cdk v2, I cant deploy my cdk app, getting “Stack name must be <= 128 characters” error message.
Looking at the stack name it tried to create, I cant understand what is going on, why is this name generated when I have provided a short logical id to all my resources and to the stack name itself.
I have a construct that exports an existing eks cluster (code is simplified just for example)
class EksCluster(Construct):
def __init__(
self,
scope: Construct,
stack_name: str,
stage: str,
) -> None:
super().__init__(scope, stack_name)
self.cluster = self.import_cluster()
def import_cluster(self) -> aws_eks.ICluster:
return aws_eks.Cluster.from_cluster_attributes(
self,
id="imported-eks-cluster",
cluster_name=cluster_name,
kubectl_role_arn=kubectl_role_arn,
open_id_connect_provider=open_id_provider,
vpc=vpc,
)
Then a simple app.py with the cdk app
app = App()
aws_lb_controller_stack = AwsLBControllerStack(
app,
f"aws-load-balancer-controller-{STAGE}",
stage=STAGE,
cluster_config=cluster_config,
env=Environment(region=REGION, account=ACCOUNT),
)
app.synth()
And finally the stack itself, that uses the construct to use the eks cluster and create a service account for example
class AwsLBControllerStack(Stack):
def __init__(
self,
scope: Construct,
construct_id: str,
stage: str,
cluster_config: dict,
**kwargs,
) -> None:
super().__init__(scope, construct_id, **kwargs)
self.eks_cluster = EksCluster(self, "eks-cluster", stage=stage)
service_account = self.eks_cluster.cluster.add_service_account(
"aws-lb-controller-service-account",
name=AWS_LB_CONTROLLER_SERVICE_ACCOUNT_NAME,
namespace=AWS_LB_CONTROLLER_NAMESPACE,
)
This worked fine on cdk v1.147.1, but now after upgrading the cdk version and trying to deploy this code, it returns the following error:
jsii.errors.JSIIError: Stack name must be <= 128 characters. Stack name: 'awsloadbalancercontrollersandboxzolaawsloadbalancercontrollersandboxzolaeksclusterimportedeksekscluster980273B4KubectlProviderC92A5312'
Can you please explain what generated such a long name? And most importantly, how can this be fixed?
Expected Behavior
Stack names should be short and understandable like they are defined in their logical ids, and most importantly it should allow me to deploy my cdk app without generating the name and then not allowing me to deploy when I did not define such name anywhere in the app.
Current Behavior
Stack names are generated with multiple duplicates inside and just unreadable names.
Reproduction Steps
Posted above a simple setup in python
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.21.1
Framework Version
No response
Node.js Version
v17.9.0
OS
macOS monterey 12.3.1
Language
Python
Language Version
3.10.2
Other information
No response
Issue Analytics
- State:
- Created a year ago
- Comments:7 (2 by maintainers)
Thanks @michaelsatish, that reproduces the issue. I’ll be working on a fix for this asap.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.