Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(synthetics): canary name can be up to 255 characters #32385

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/aws-cdk-lib/aws-synthetics/lib/canary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}")`);
Expand Down
12 changes: 6 additions & 6 deletions packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand Down
Loading