-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
(pipelines): envFromCfnOutputs does not work when stacks have a long artifactId #17436
Comments
The solution is to limit the length of the automatically generated namespace names |
@rix0rrr will it be possible to fix this without breaking existing stacks? Also wondering how we avoid name collisions if we truncate the id. |
The variable namespace identifier in CodePipeline allows a maximum of 100 characters. If we ever come up with an identifier that would be too long, trim it down. While writing tests for this, discovered that actions exhibited the same length issues, and did the same there too. Fixes #17436.
The variable namespace identifier in CodePipeline allows a maximum of 100 characters. If we ever come up with an identifier that would be too long, trim it down. While writing tests for this, discovered that actions exhibited the same length issues, and did the same there too. Fixes #17436. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
@ericzbeard - thanks! I tested this with the sample repo from my PR description (locally linking via these steps: https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md#linking-against-this-repository) and I no longer receive the error when running synth! |
The variable namespace identifier in CodePipeline allows a maximum of 100 characters. If we ever come up with an identifier that would be too long, trim it down. While writing tests for this, discovered that actions exhibited the same length issues, and did the same there too. Fixes aws#17436. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
What is the problem?
When using
envFromCfnOutputs
to pass an output to aShellStep
, thesynth
fails if the producing stack has a longartifactId
(e.g., a longID
property):Error: Namespace name must match regular expression: /^[A-Za-z0-9@_-]{1,100}$/, got '<long artifact id>'
Reproduction Steps
CfnOutput
in aShellStep
. See https://github.com/blimmer/cdk-bug-reports/compare/variable-namespace-bug?expand=1 for thediff
from a standardcdk init
template.cd cdk-bug-reports
npm ci
npx cdk synth
Observe:
You can also see this failure in GitHub actions: https://github.com/blimmer/cdk-bug-reports/actions/runs/1441330663
What did you expect to happen?
I expected the
synth
to not throw an error. Even though the name is quite long, I expected CDK internals to trim theartifactId
to be within the 100 character limit.What actually happened?
A runtime error was thrown:
Error: Namespace name must match regular expression: /^[A-Za-z0-9@_-]{1,100}$/, got 'PipelineStackProdAVeryVeryLongIdThatProbablyHasSomePurposeBeingSoLongButDoesSeemALittleBitEgregiousJustSayinDC4EA63E'
CDK CLI Version
1.132.0 (build 5c75891)
Framework Version
No response
Node.js Version
14.17.6
OS
MacOS
Language
Typescript
Language Version
Version 3.9.10
Other information
Although the example attached via the repro steps seems unusual, stacks deployed with pipelines automatically get the Pipeline ID and Stage ID prepended to the Stack ID. The stack also automatically gets a 9 character ID added to the end.
So, realistically, of the maximum 100 character limit, quite a bit of it is already taken up by the pipeline / stage / suffix that's automatically added.
It would be nice if CDK automatically determined that the artifact ID was going to be too long and trimmed it for me. I see there's already a method that could potentially do this (
aws-cdk/packages/@aws-cdk/pipelines/lib/codepipeline/_codebuild-factory.ts
Lines 450 to 452 in e2f2a97
Although, it doesn't look like that method is used consistently, e.g., here where
artifactId
is accessed directly: https://github.com/blimmer/aws-cdk/blob/e2f2a972df588ab760bcd7b6f3c9d2f49741f489/packages/@aws-cdk/pipelines/lib/blueprint/shell-step.ts#L255-L258The text was updated successfully, but these errors were encountered: