Skip to content

Commit 231e1bf

Browse files
authored
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*
1 parent 453045b commit 231e1bf

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

packages/aws-cdk-lib/aws-synthetics/lib/canary.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,8 @@ const nameRegex: RegExp = /^[0-9a-z_\-]+$/;
745745
* @param name - the given name of the canary
746746
*/
747747
function validateName(name: string) {
748-
if (name.length > 21) {
749-
throw new Error(`Canary name is too large, must be between 1 and 21 characters, but is ${name.length} (got "${name}")`);
748+
if (name.length > 255) {
749+
throw new Error(`Canary name is too large, must be between 1 and 255 characters, but is ${name.length} (got "${name}")`);
750750
}
751751
if (!nameRegex.test(name)) {
752752
throw new Error(`Canary name must be lowercase, numbers, hyphens, or underscores (got "${name}")`);

packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,23 @@ test('Throws when name is specified incorrectly', () => {
104104
}),
105105
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_8_0,
106106
}))
107-
.toThrowError('Canary name must be lowercase, numbers, hyphens, or underscores (got "My Canary")');
107+
.toThrow('Canary name must be lowercase, numbers, hyphens, or underscores (got "My Canary")');
108108
});
109109

110-
test('Throws when name has more than 21 characters', () => {
110+
test('Throws when name has more than 255 characters', () => {
111111
// GIVEN
112112
const stack = new Stack();
113113

114114
// THEN
115115
expect(() => new synthetics.Canary(stack, 'Canary', {
116-
canaryName: 'a'.repeat(22),
116+
canaryName: 'a'.repeat(256),
117117
test: synthetics.Test.custom({
118118
handler: 'index.handler',
119119
code: synthetics.Code.fromInline('/* Synthetics handler code */'),
120120
}),
121121
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_8_0,
122122
}))
123-
.toThrowError(`Canary name is too large, must be between 1 and 21 characters, but is 22 (got "${'a'.repeat(22)}")`);
123+
.toThrow(`Canary name is too large, must be between 1 and 255 characters, but is 256 (got "${'a'.repeat(256)}")`);
124124
});
125125

126126
test('An existing role can be specified instead of auto-created', () => {
@@ -561,7 +561,7 @@ test('Throws when rate above 60 minutes', () => {
561561
}),
562562
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_8_0,
563563
}))
564-
.toThrowError('Schedule duration must be between 1 and 60 minutes');
564+
.toThrow('Schedule duration must be between 1 and 60 minutes');
565565
});
566566

567567
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', () => {
577577
}),
578578
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_8_0,
579579
}))
580-
.toThrowError('\'59 seconds\' cannot be converted into a whole number of minutes.');
580+
.toThrow('\'59 seconds\' cannot be converted into a whole number of minutes.');
581581
});
582582

583583
test('Can share artifacts bucket between canaries', () => {

0 commit comments

Comments
 (0)