Skip to content

(cli): tags with an equals sign in the value only use the value of the string prior to the equals sign #21003

@peterwoodworth

Description

@peterwoodworth

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

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

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.effort/smallSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdp1package/toolsRelated to AWS CDK Tools or CLI

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions