diff --git a/packages/aws-cdk/lib/settings.ts b/packages/aws-cdk/lib/settings.ts index e24ca92468162..f8a4b0b789dd4 100644 --- a/packages/aws-cdk/lib/settings.ts +++ b/packages/aws-cdk/lib/settings.ts @@ -336,7 +336,7 @@ export class Settings { const tags: Tag[] = []; for (const assignment of nonEmptyTags) { - const parts = assignment.split('=', 2); + const parts = assignment.split(/=(.*)/, 2); if (parts.length === 2) { debug('CLI argument tags: %s=%s', parts[0], parts[1]); tags.push({ diff --git a/packages/aws-cdk/test/settings.test.ts b/packages/aws-cdk/test/settings.test.ts index 0738febc435c0..fde5c1c74665c 100644 --- a/packages/aws-cdk/test/settings.test.ts +++ b/packages/aws-cdk/test/settings.test.ts @@ -1,5 +1,6 @@ /* eslint-disable import/order */ import { Command, Context, Settings } from '../lib/settings'; +import { Tag } from '../lib/cdk-toolkit'; test('can delete values from Context object', () => { // GIVEN @@ -81,6 +82,26 @@ test('can parse string context from command line arguments with equals sign in v expect(settings2.get(['context']).foo).toEqual( 'bar='); }); +test('can parse tag values from command line arguments', () => { + // GIVEN + const settings1 = Settings.fromCommandLineArguments({ tags: ['foo=bar'], _: [Command.DEPLOY] }); + const settings2 = Settings.fromCommandLineArguments({ tags: ['foo='], _: [Command.DEPLOY] }); + + // THEN + expect(settings1.get(['tags']).find((tag: Tag) => tag.Key === 'foo').Value).toEqual('bar'); + expect(settings2.get(['tags']).find((tag: Tag) => tag.Key === 'foo').Value).toEqual(''); +}); + +test('can parse tag values from command line arguments with equals sign in value', () => { + // GIVEN + const settings1 = Settings.fromCommandLineArguments({ tags: ['foo==bar='], _: [Command.DEPLOY] }); + const settings2 = Settings.fromCommandLineArguments({ tags: ['foo=bar='], _: [Command.DEPLOY] }); + + // THEN + expect(settings1.get(['tags']).find((tag: Tag) => tag.Key === 'foo').Value).toEqual('=bar='); + expect(settings2.get(['tags']).find((tag: Tag) => tag.Key === 'foo').Value).toEqual('bar='); +}); + test('bundling stacks defaults to an empty list', () => { // GIVEN const settings = Settings.fromCommandLineArguments({