-
Notifications
You must be signed in to change notification settings - Fork 4.5k
(cli): tags with an equals sign in the value only use the value of the string prior to the equals sign #21003
Copy link
Copy link
Closed
Labels
bugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdRelated to contributions. See CONTRIBUTING.mdp1package/toolsRelated to AWS CDK Tools or CLIRelated to AWS CDK Tools or CLI
Description
Describe the bug
If you need a tag with a key value pair such as
Key : MyKey
Value : MyValue=Something
The stack will have a key value pair that shows
Key: MyKey
Value: MyValue
Expected Behavior
I would expect the value of the tag to be MyValue=Something
Current Behavior
Doesn't read the full tag value
Reproduction Steps
Try to create a stack with a tag that has an equals sign in the value
Possible Solution
The code which parses tags in the command line will split when it sees an equals sign, and will only use the second split value as the tag value, when it should be everything after the first split
aws-cdk/packages/aws-cdk/lib/settings.ts
Lines 327 to 348 in a7e3eab
| private static parseStringTagsListToObject(argTags: string[] | undefined): Tag[] | undefined { | |
| if (argTags === undefined) { return undefined; } | |
| if (argTags.length === 0) { return undefined; } | |
| const nonEmptyTags = argTags.filter(t => t !== ''); | |
| if (nonEmptyTags.length === 0) { return []; } | |
| const tags: Tag[] = []; | |
| for (const assignment of nonEmptyTags) { | |
| const parts = assignment.split('=', 2); | |
| if (parts.length === 2) { | |
| debug('CLI argument tags: %s=%s', parts[0], parts[1]); | |
| tags.push({ | |
| Key: parts[0], | |
| Value: parts[1], | |
| }); | |
| } else { | |
| warning('Tags argument is not an assignment (key=value): %s', assignment); | |
| } | |
| } | |
| return tags.length > 0 ? tags : undefined; | |
| } |
Additional Information/Context
No response
CDK CLI Version
.
Framework Version
No response
Node.js Version
.
OS
.
Language
Typescript
Language Version
No response
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdRelated to contributions. See CONTRIBUTING.mdp1package/toolsRelated to AWS CDK Tools or CLIRelated to AWS CDK Tools or CLI