Skip to content

Conversation

@badmintoncryer
Copy link
Contributor

Issue # (if applicable)

None

Reason for this change

AWS CloudWatch synthetics supports for performing safe canary update.

This feature cannot be configurable from AWS CDK L2 construct.

Description of changes

  • Add dryRunAndUpdate prop to canaryProps
  • Add runtime validation
    • syn-nodejs-puppeteer-10.0+
    • syn-nodejs-playwright-2.0+
    • syn-python-selenium-5.1+

Describe any new or updated permissions being added

None

Description of how you validated changes

Add both unit and integ tets.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team June 2, 2025 15:15
@github-actions github-actions bot added p2 distinguished-contributor [Pilot] contributed 50+ PRs to the CDK labels Jun 2, 2025
@badmintoncryer badmintoncryer changed the title feat: safe canary update feat(synthetics): safe canary update Jun 2, 2025
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jun 2, 2025
Copy link
Contributor

@mazyu36 mazyu36 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution.
Some minor comments.

}

private validateDryRunAndUpdate(runtime: Runtime, dryRunAndUpdate?: boolean) {
if (dryRunAndUpdate === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is validation needed when dryRunAndUpdate is false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right! I've updated to validate when only dryRunAndUpdate is true.

}
}

private validateDryRunAndUpdate(runtime: Runtime, dryRunAndUpdate?: boolean) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this validation seems a bit overkilled. But I'd like to wait for the maintainers' opinion on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation adds value, but it could be simplified. Could you please explain why you did not use the available runtime values to check against? Having a collection of the supported runtime versions and then checking if the provided one is any of the supported ones would likely be a simpler approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature is defined as being available in versions syn-nodejs-puppeteer-10.0+, syn-nodejs-playwright-2.0+, and syn-python-selenium-5.1+. Currently, only puppeteer-10.0, playwright-2.0, and selenium-5.1 are the available versions, but they should continue to increase in the future.
I think it would be quite cumbersome to keep updating the available versions each time this happens.
What are your thoughts on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@alvazjor alvazjor Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating the collection to add future supported versions may be cumbersome, but the same applies to handling future deprecated versions. At some point, the minimum supported version could be deprecated, requiring an update to the logic. This is likely an unavoidable aspect of the project.

With that in mind, I'd still rather have a simpler logic in place. So what do you think about using a regex expression that separates the runtimeName string into the runtime family ('syn-nodejs-puppeteer', 'syn-nodejs-playwright', etc) and the version number? We could keep a single object (let's say it's called MIN_SUPPORTED_VERSIONS or something similar) that has the supported family names as the keys, and the minimum version as the values. Then, you will just need to match the runtimeName to the regex and use the object to see if the matched family exists in the MIN_SUPPORTED_VERSIONS and if the version part is equal to or greater than the value of that key.

Something like:

const RUNTIME_REGEX = /^syn-(nodejs-puppeteer|nodejs-playwright|python-selenium)-(\d+\.\d+)$/;
const MIN_SUPPORTED_VERSIONS: { [family: string]: number } = {
  'nodejs-puppeteer': 10.0,
  'nodejs-playwright': 2.0,
  'python-selenium': 5.1
};

 const match = runtimeName.match(RUNTIME_REGEX);

  // If the runtime name doesn't match our expected pattern, it's not supported
  if (!match || match.length < 3) {
    return false;
  }

  const family = match[1];
  const version = parseFloat(match[2]);
  const minVersion = MIN_SUPPORTED_VERSIONS[family];


  // Check if this family is in our object and if the version meets the minimum
  return minVersion !== undefined && version >= minVersion;

what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alvazjor Thank you for your suggestion. I've updated my implementation like that. Could you please confirm again?

@badmintoncryer
Copy link
Contributor Author

@mazyu36 Thank you for your review! I've updated my implementation.

IMO, this validation seems a bit overkilled. But I'd like to wait for the maintainers' opinion on this.

I can understand your opinion. I'll also wait for maintainer's review.

Copy link
Contributor

@mazyu36 mazyu36 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. LGTM.

@aws-cdk-automation aws-cdk-automation added pr/needs-maintainer-review This PR needs a review from a Core Team Member and removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Jun 4, 2025
@alvazjor alvazjor self-assigned this Jun 4, 2025
@alvazjor
Copy link
Contributor

alvazjor commented Jun 4, 2025

@badmintoncryer Thank you for your contribution. Added one comment.

Copy link
Contributor

@alvazjor alvazjor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution

@mergify
Copy link
Contributor

mergify bot commented Jun 10, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jun 10, 2025
@mergify
Copy link
Contributor

mergify bot commented Jun 10, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 7ed59b4
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Jun 10, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 89c5350 into aws:main Jun 10, 2025
16 checks passed
@github-actions
Copy link
Contributor

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 Jun 10, 2025
@badmintoncryer badmintoncryer deleted the canary branch June 10, 2025 13:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants