From 231e1bf98597bcaf90a75632f9e217fbf33d585a Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <36202692+kaizencc@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:48:16 -0500 Subject: [PATCH] fix(synthetics): canary name can be up to 255 characters (#32385) Fixes #32376 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/aws-cdk-lib/aws-synthetics/lib/canary.ts | 4 ++-- .../aws-cdk-lib/aws-synthetics/test/canary.test.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index 365b73882f810..385a13dcda254 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -745,8 +745,8 @@ const nameRegex: RegExp = /^[0-9a-z_\-]+$/; * @param name - the given name of the canary */ function validateName(name: string) { - if (name.length > 21) { - throw new Error(`Canary name is too large, must be between 1 and 21 characters, but is ${name.length} (got "${name}")`); + if (name.length > 255) { + throw new Error(`Canary name is too large, must be between 1 and 255 characters, but is ${name.length} (got "${name}")`); } if (!nameRegex.test(name)) { throw new Error(`Canary name must be lowercase, numbers, hyphens, or underscores (got "${name}")`); diff --git a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts index 286997bd98de9..554553c2be01c 100644 --- a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts +++ b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts @@ -104,23 +104,23 @@ test('Throws when name is specified incorrectly', () => { }), runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_8_0, })) - .toThrowError('Canary name must be lowercase, numbers, hyphens, or underscores (got "My Canary")'); + .toThrow('Canary name must be lowercase, numbers, hyphens, or underscores (got "My Canary")'); }); -test('Throws when name has more than 21 characters', () => { +test('Throws when name has more than 255 characters', () => { // GIVEN const stack = new Stack(); // THEN expect(() => new synthetics.Canary(stack, 'Canary', { - canaryName: 'a'.repeat(22), + canaryName: 'a'.repeat(256), test: synthetics.Test.custom({ handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_8_0, })) - .toThrowError(`Canary name is too large, must be between 1 and 21 characters, but is 22 (got "${'a'.repeat(22)}")`); + .toThrow(`Canary name is too large, must be between 1 and 255 characters, but is 256 (got "${'a'.repeat(256)}")`); }); test('An existing role can be specified instead of auto-created', () => { @@ -561,7 +561,7 @@ test('Throws when rate above 60 minutes', () => { }), runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_8_0, })) - .toThrowError('Schedule duration must be between 1 and 60 minutes'); + .toThrow('Schedule duration must be between 1 and 60 minutes'); }); test('Throws when rate above is not a whole number of minutes', () => { @@ -577,7 +577,7 @@ test('Throws when rate above is not a whole number of minutes', () => { }), runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_8_0, })) - .toThrowError('\'59 seconds\' cannot be converted into a whole number of minutes.'); + .toThrow('\'59 seconds\' cannot be converted into a whole number of minutes.'); }); test('Can share artifacts bucket between canaries', () => {