-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
After upgrading to cdk v2, getting Stack name must be <= 128 characters #20124
Comments
I ran into the problem stated here, and am unable to move forward in completing my CDK application. Just wondering if any timeline is established for this to get resolved? |
The way I could solve this issue, was to shorten the base stack name to something unreadable (because I had to remove a lot of letters). This also created a downtime for our system because I had to delete the stack first and only then re-deploy with the shorten name. |
@Alon-Katz Thank you for the comment. I can synthesize the stack with shorten name. No ideal, but works till this gets fixed. |
@michaelsatish how is
This was present in the template produced by this app. Stack code:
app.py:
|
Hi @comcalvi, Here is an example stack code to reproduce the error. Hope this helps. package versions app.py #!/usr/bin/env python3
from aws_cdk import App
from pipeline import PipelineStack
app = App()
PipelineStack(app, "ApplicationPipelineStack")
app.synth() pipeline.py from aws_cdk import Stack
from aws_cdk import aws_s3 as s3
from aws_cdk import pipelines
from constructs import Construct
from stages import ApplicationStage
class PipelineStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
bucket = s3.Bucket(self, "ApplicationCodeBucket")
the_pipeline = pipelines.CodePipeline(
self,
"CdkPipeline",
self_mutation=False,
synth=pipelines.ShellStep(
id="Synth",
input=pipelines.CodePipelineSource.s3(bucket, "code"),
commands=[
"npm install -g aws-cdk@latest",
"python3 -m pip install --user pipenv",
"pipenv install --deploy --system",
],
),
)
application_stage = ApplicationStage(self, "ApplicationStage")
the_pipeline.add_stage(application_stage) stages.py from aws_cdk import Stage
from constructs import Construct
from stacks import ApplicationStack
class ApplicationStage(Stage):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
_ = ApplicationStack(self, "ApplicationStack") stacks.py from aws_cdk import Stack
from aws_cdk import aws_eks as eks
from aws_cdk import aws_iam as iam
from constructs import Construct
class ApplicationStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
cluster = eks.Cluster.from_cluster_attributes(
self,
"ApplicationCluster",
cluster_name="ApplicationDevCluster",
kubectl_role_arn="arn:aws:iam::12345:role/service-role/AmazonExample",
open_id_connect_provider=iam.OpenIdConnectProvider(
self, "ApplicationClusterIdentityProvider", url="http://"
),
)
service_acount = cluster.add_service_account("ApplicationServiceAccount")
cluster.add_helm_chart(
"ApplicationHelmChart",
chart="nginx-ingress",
repository="https://helm.nginx.com/stable",
namespace="kube-system",
values={"service_acount": service_acount.service_account_name},
) cdk ls
jsii.errors.JSIIError: Stack name must be <= 128 characters. Stack name: 'ApplicationStage-ApplicationStackApplicationPipelineStackApplicationStageApplicationStackApplicationClusterF3918940KubectlProvider5C2B31FB' |
Thanks @michaelsatish, that reproduces the issue. I'll be working on a fix for this asap. |
When imported, Kubectl Providers result in a new nested stack being created. Nested stack names are created by generating a unique ID (which includes the entire construct id path). Kubectl provider ids are constructed the same way (they can't be specified manually, so the code uses a unique ID). This results in the final ID for the stack containing the id of the provider repeated twice. The makes the name hard to decipher, and more importantly can result in stack names being longer than 128 characters. This caps all generated stack names at 128 characters. Ideally, we would be able to change way in which these stack names are generated; however, that would be a breaking change. Fixes #20124. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Describe 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)
Then a simple app.py with the cdk app
And finally the stack itself, that uses the construct to use the eks cluster and create a service account for example
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:
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
The text was updated successfully, but these errors were encountered: