Skip to content
New issue

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

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

Already on GitHub? # to your account

aws-synthetics: canary name limit is inconsistent with the API #32376

Closed
1 task
regmicmahesh opened this issue Dec 4, 2024 · 3 comments · Fixed by #32385
Closed
1 task

aws-synthetics: canary name limit is inconsistent with the API #32376

regmicmahesh opened this issue Dec 4, 2024 · 3 comments · Fixed by #32385
Labels
@aws-cdk/aws-synthetics Related to Amazon CloudWatch Synthetics bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@regmicmahesh
Copy link

regmicmahesh commented Dec 4, 2024

Describe the bug

When I set the canaryName via cdk code then it says the maximum allowed character is 21. But when I do the same thing on AWS Management Console, I can have upto 255 characters.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

I expected the CDK to have the same limit to the AWS Management Console API.

Current Behavior

I'm getting this error.

Error: Canary name is too large, must be between 1 and 21 characters, but is 29 (got "Generiskinvalid_id_case_12345")

Reproduction Steps

Create a synthetic resource with canaryName string having length of more than 21 characters.

        new aws_synthetics.Canary(this, cdkLogicalId, {
          schedule: aws_synthetics.Schedule.rate(cdk.Duration.minutes(5)),
          canaryName: cdkLogicalId,
          vpc: vpc,
          vpcSubnets: { subnetGroupName: "Private" },
          runtime: aws_synthetics.Runtime.SYNTHETICS_PYTHON_SELENIUM_4_0,
          test: aws_synthetics.Test.custom({
            code: codeAsset,
            handler: `${canaryNameWithoutExt}.handler`,
          }),
          timeout: cdk.Duration.minutes(1),
          startAfterCreation: false,
        });
      });

Possible Solution

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 (!nameRegex.test(name)) {
throw new Error(`Canary name must be lowercase, numbers, hyphens, or underscores (got "${name}")`);
}

In this file, we should update the comparison to be length > 255.

Additional Information/Context

No response

CDK CLI Version

2.162.1 (build 10aa526)

Framework Version

No response

Node.js Version

v18.18.2

OS

Terminal

Language

TypeScript

Language Version

"aws-cdk-lib": "^2.171.0"

Other information

No response

@regmicmahesh regmicmahesh added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 4, 2024
@github-actions github-actions bot added the @aws-cdk/aws-synthetics Related to Amazon CloudWatch Synthetics label Dec 4, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 and removed needs-triage This issue or PR still needs to be triaged. labels Dec 4, 2024
@khushail khushail self-assigned this Dec 4, 2024
@khushail
Copy link
Contributor

khushail commented Dec 4, 2024

Hi @regmicmahesh , thanks for reporting this. Yes, I can see the difference in the limit as its mentioned 255 chars in AWS docs -https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html

Screenshot 2024-12-04 at 11 04 05 AM

Cloudformation docs also specify the 255 char limit for canary name -

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html#cfn-synthetics-canary-name

@khushail khushail added effort/small Small work item – less than a day of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Dec 4, 2024
@khushail khushail removed their assignment Dec 4, 2024
@mergify mergify bot closed this as completed in #32385 Dec 9, 2024
@mergify mergify bot closed this as completed in 231e1bf Dec 9, 2024
Copy link

github-actions bot commented Dec 9, 2024

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

1 similar comment
Copy link

github-actions bot commented Dec 9, 2024

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 9, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
@aws-cdk/aws-synthetics Related to Amazon CloudWatch Synthetics bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants