-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/stackname validation #2
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
base: main
Are you sure you want to change the base?
Conversation
| .check((argv) => { | ||
| if (argv.stack) { | ||
| const identifierRegex = /^[a-zA-Z][-_a-zA-Z0-9/]*$/; | ||
| if (!argv.stack.match(identifierRegex)) { | ||
| throw new AmplifyUserError('InvalidStackNameError', { | ||
| message: `Invalid stack name: ${argv.stack}`, | ||
| resolution: | ||
| 'Stack name must start with a letter and can only contain alphanumeric characters, hyphens, underscores and slashes.', | ||
| }); | ||
| } | ||
| } | ||
| return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't solve the problem.
I ran the command with something that looks like nested stack and the validation error is coming from different place than CLI. See:
bcd0740fa72c:testapp057 sobkamil$ npx ampx generate outputs --stack ParentStackA/InsdeWhichAnotherIsInstatiatedStack --debug
ampx generate outputs
Generates Amplify backend outputs
Stack identifier
--stack A stack name that contains an Amplify backend [string]
Project identifier
--app-id The Amplify App ID of the project [string]
--branch A git branch of the Amplify project [string]
Options:
--debug Print debug logs to the console [boolean] [default: false]
--help Show help [boolean]
--profile An AWS profile name. [string]
--format The format which the configuration should be exported into.
[string] [choices: "mjs", "json", "json-mobile", "ts", "dart"]
--out-dir A path to directory where config is written. If not provide
d defaults to current process working directory. [string]
--outputs-version Version of the configuration. Version 0 represents classic
amplify-cli config file amplify-configuration and 1 represe
nts newer config file amplify_outputs
[string] [choices: "0", "1", "1.1", "1.2"] [default: "1.2"]
ValidationError: 1 validation error detected: Value 'ParentStackA/InsdeWhichAnotherIsInstatiatedStack' at 'stackName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]*|arn:[-a-zA-Z0-9:/._+]*
[DEBUG] 2024-10-15T22:12:17.609Z: ValidationError: 1 validation error detected: Value 'ParentStackA/InsdeWhichAnotherIsInstatiatedStack' at 'stackName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]*|arn:[-a-zA-Z0-9:/._+]*
at throwDefaultError (/Users/sobkamil/git/amplify-backend/node_modules/@smithy/smithy-client/dist-cjs/index.js:844:20)
at /Users/sobkamil/git/amplify-backend/node_modules/@smithy/smithy-client/dist-cjs/index.js:853:5
at de_CommandError (/Users/sobkamil/git/amplify-backend/node_modules/@aws-sdk/client-cloudformation/dist-cjs/index.js:3270:14)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /Users/sobkamil/git/amplify-backend/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
at async /Users/sobkamil/git/amplify-backend/node_modules/@smithy/core/dist-cjs/index.js:165:18
at async /Users/sobkamil/git/amplify-backend/node_modules/@smithy/middleware-retry/dist-cjs/index.js:320:38
at async /Users/sobkamil/git/amplify-backend/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22
at async StackMetadataBackendOutputRetrievalStrategy.fetchBackendOutput (file:///Users/sobkamil/git/amplify-backend/packages/deployed-backend-client/lib/stack_metadata_output_retrieval_strategy.js:28:37)
at async DefaultBackendOutputClient.getOutput (file:///Users/sobkamil/git/amplify-backend/packages/deployed-backend-client/lib/backend_output_client.js:18:24)
I.e. it's coming from here https://github.com/aws-amplify/amplify-backend/blob/fb3538c58cfb25b6ae8aa5d4036be05bf1ee2181/packages/deployed-backend-client/src/stack_metadata_output_retrieval_strategy.ts#L45-L47 .
I've identified that we need to modify the 'stack' option in the 'builder' method to allow slashes in stack names. I will update the validation logic for the 'stack' option to permit slashes.