From 87139ab2eeae96df9d775118b870cfb326438197 Mon Sep 17 00:00:00 2001 From: Jimmy Gaussen Date: Fri, 15 Mar 2024 15:35:31 +0100 Subject: [PATCH 1/2] chore(synthetics): update runtimes (#29446) ### Issue # (if applicable) Could not find any in the backlog ### Reason for this change Update the CDK listed Synthetics runtimes to match the current availability, as well as add missing deprecated versions ### Description of changes * Added new runtimes * Marked existing runtimes as deprecated * Add previously deprecated runtimes * For the sake of consistency and readability, the static fields for `syn-1.0` and `syn-nodejs-2.*` were still named `SYNTHETICS_NODEJS_PUPPETEER_*` * Fix documented versions for existing runtimes * Added `{@link}` tags to match the web documentation ### Description of how you validated changes I compared the current CDK versions to live SDK data, using the `synthetics:DescribeRuntimeVersions` API results. Deprecated versions were established using the `DeprecationDate` field ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-cdk-lib/aws-synthetics/lib/runtime.ts | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/runtime.ts b/packages/aws-cdk-lib/aws-synthetics/lib/runtime.ts index f56b3f2114927..9c4acfa496bfa 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/runtime.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/runtime.ts @@ -25,9 +25,12 @@ export class Runtime { /** * `syn-nodejs-puppeteer-3.5` includes the following: * - Lambda runtime Node.js 14.x - * - Puppeteer-core version 10.1.0 + * - Puppeteer-core version 5.5.0 * - Chromium version 92.0.4512 * + * New features: + * - **Updated dependencies**: The only new features in this runtime are the updated dependencies. + * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-nodejs-puppeteer-3.5 * @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS Puppeteer runtime. */ @@ -36,7 +39,7 @@ export class Runtime { /** * `syn-nodejs-puppeteer-3.6` includes the following: * - Lambda runtime Node.js 14.x - * - Puppeteer-core version 10.1.0 + * - Puppeteer-core version 5.5.0 * - Chromium version 92.0.4512 * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-nodejs-puppeteer-3.6 @@ -47,7 +50,7 @@ export class Runtime { /** * `syn-nodejs-puppeteer-3.7` includes the following: * - Lambda runtime Node.js 14.x - * - Puppeteer-core version 10.1.0 + * - Puppeteer-core version 5.5.0 * - Chromium version 92.0.4512 * * New Features: @@ -169,7 +172,7 @@ export class Runtime { * New Features: * - **Stability improvements**: Added auto-retry logic for handling intermittent Puppeteer launch errors. * - **Dependency upgrades**: Upgrades for some third-party dependency packages. - * - **Canaries without Amazon S3 permissions**: Bug fixes, such that canaries that don't have any Amazon S3 permissions can still run. These canaries with no Amazon S3 permissions won't be able to upload screenshots or other artifacts to Amazon S3. For more information about permissions for canaries, see Required roles and permissions for canaries. + * - **Canaries without Amazon S3 permissions**: Bug fixes, such that canaries that don't have any Amazon S3 permissions can still run. These canaries with no Amazon S3 permissions won't be able to upload screenshots or other artifacts to Amazon S3. For more information about permissions for canaries, see {@link https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_CanaryPermissions.html | Required roles and permissions for canaries}. * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-nodejs-puppeteer-6.1 * @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS Puppeteer runtime. @@ -191,6 +194,19 @@ export class Runtime { */ public static readonly SYNTHETICS_NODEJS_PUPPETEER_6_2 = new Runtime('syn-nodejs-puppeteer-6.2', RuntimeFamily.NODEJS); + /** + * `syn-nodejs-puppeteer-7.0` includes the following: + * - Lambda runtime Node.js 18.x + * - Puppeteer-core version 21.9.0 + * - Chromium version 121.0.6167.139 + * + * New Features: + * - **Updated versions of the bundled libraries in Puppeteer and Chromium**: The Puppeteer and Chromium dependencies are updated to new versions. + * + * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-nodejs-puppeteer-7.0 + */ + public static readonly SYNTHETICS_NODEJS_PUPPETEER_7_0 = new Runtime('syn-nodejs-puppeteer-7.0', RuntimeFamily.NODEJS); + /** * `syn-python-selenium-1.0` includes the following: * - Lambda runtime Python 3.8 @@ -198,6 +214,7 @@ export class Runtime { * - Chromium version 83.0.4103.0 * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_python_selenium.html#CloudWatch_Synthetics_runtimeversion-syn-python-selenium-1.0 + * @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Python Selenium runtime. */ public static readonly SYNTHETICS_PYTHON_SELENIUM_1_0 = new Runtime('syn-python-selenium-1.0', RuntimeFamily.PYTHON); @@ -214,6 +231,7 @@ export class Runtime { * - **Cross-Region artifact buckets**: A canary can store its artifacts in an Amazon S3 bucket in a different Region. * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_python_selenium.html#CloudWatch_Synthetics_runtimeversion-syn-python-selenium-1.1 + * @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Python Selenium runtime. */ public static readonly SYNTHETICS_PYTHON_SELENIUM_1_1 = new Runtime('syn-python-selenium-1.1', RuntimeFamily.PYTHON); @@ -227,6 +245,7 @@ export class Runtime { * - **Updated dependencies**: The only new features in this runtime are the updated dependencies. * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_python_selenium.html#CloudWatch_Synthetics_runtimeversion-syn-python-selenium-1.2 + * @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Python Selenium runtime. */ public static readonly SYNTHETICS_PYTHON_SELENIUM_1_2 = new Runtime('syn-python-selenium-1.2', RuntimeFamily.PYTHON); @@ -240,6 +259,7 @@ export class Runtime { * - **More precise timestamps**: The start time and stop time of canary runs are now precise to the millisecond. * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_python_selenium.html#CloudWatch_Synthetics_runtimeversion-syn-python-selenium-1.3 + * @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Python Selenium runtime. */ public static readonly SYNTHETICS_PYTHON_SELENIUM_1_3 = new Runtime('syn-python-selenium-1.3', RuntimeFamily.PYTHON); @@ -256,7 +276,9 @@ export class Runtime { * Bug fixes: * - **Timestamp added**: A timestamp has been added to canary logs. * - **Session re-use**: A bug was fixed so that canaries are now prevented from reusing the session from their previous canary run. + * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_python_selenium.html#CloudWatch_Synthetics_runtimeversion-syn-python-selenium-2.0 + * @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Python Selenium runtime. */ public static readonly SYNTHETICS_PYTHON_SELENIUM_2_0 = new Runtime('syn-python-selenium-2.0', RuntimeFamily.PYTHON); @@ -273,6 +295,19 @@ export class Runtime { */ public static readonly SYNTHETICS_PYTHON_SELENIUM_2_1 = new Runtime('syn-python-selenium-2.1', RuntimeFamily.PYTHON); + /** + * `syn-python-selenium-3.0` includes the following: + * - Lambda runtime Python 3.8 + * - Selenium version 4.15.1 + * - Chromium version 121.0.6167.139 + * + * New Features: + * - **Updated versions of the bundled libraries in Chromium**: The Chromium dependency is updated to a new version. + * + * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_python_selenium.html#CloudWatch_Synthetics_runtimeversion-syn-python-selenium-3.0 + */ + public static readonly SYNTHETICS_PYTHON_SELENIUM_3_0 = new Runtime('syn-python-selenium-3.0', RuntimeFamily.PYTHON); + /** * @param name The name of the runtime version * @param family The Lambda runtime family From f2ad98027a896228c554985e746107a4c7089f70 Mon Sep 17 00:00:00 2001 From: Xia Zhao <78883180+xazhao@users.noreply.github.com> Date: Fri, 15 Mar 2024 09:58:50 -0700 Subject: [PATCH 2/2] fix(cloudwatch): unrecognized statistic warning when using percentileRank statistic in Stats helper (#29498) ### Issue # (if applicable) Closes #29465. ### Reason for this change There shouldn't be a warning when `Stats.percentileRank` ### Description of changes Add a new parser for percentileRank statistic ### Description of how you validated changes unit test ### Checklist - [ ] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-cloudwatch/lib/private/statistic.ts | 9 +++++++++ .../aws-cdk-lib/aws-cloudwatch/test/stats.test.ts | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/packages/aws-cdk-lib/aws-cloudwatch/lib/private/statistic.ts b/packages/aws-cdk-lib/aws-cloudwatch/lib/private/statistic.ts index 395f347e97ebf..80e05f26488d7 100644 --- a/packages/aws-cdk-lib/aws-cloudwatch/lib/private/statistic.ts +++ b/packages/aws-cdk-lib/aws-cloudwatch/lib/private/statistic.ts @@ -34,6 +34,10 @@ export interface PercentileStatistic extends SingleStatistic { statName: 'percentile'; } +export interface PercentileRankStatistic extends PairStatistic { + statName: 'percentileRank'; +} + export interface TrimmedMeanStatistic extends PairStatistic { statName: 'trimmedMean'; } @@ -154,6 +158,7 @@ export function parseStatistic( ): | SimpleStatistic | PercentileStatistic + | PercentileRankStatistic | TrimmedMeanStatistic | WinsorizedMeanStatistic | TrimmedCountStatistic @@ -188,6 +193,10 @@ export function parseStatistic( m = parseSingleStatistic(stat, 'p'); if (m) return { ...m, statName: 'percentile' } as PercentileStatistic; + // Percentile Rank statistics + m = parsePairStatistic(stat, 'pr'); + if (m) return { ...m, statName: 'percentileRank' } as PercentileRankStatistic; + // Trimmed mean statistics m = parseSingleStatistic(stat, 'tm') || parsePairStatistic(stat, 'tm'); if (m) return { ...m, statName: 'trimmedMean' } as TrimmedMeanStatistic; diff --git a/packages/aws-cdk-lib/aws-cloudwatch/test/stats.test.ts b/packages/aws-cdk-lib/aws-cloudwatch/test/stats.test.ts index 0a65ae2e143de..f2b399e243c79 100644 --- a/packages/aws-cdk-lib/aws-cloudwatch/test/stats.test.ts +++ b/packages/aws-cdk-lib/aws-cloudwatch/test/stats.test.ts @@ -1,5 +1,20 @@ +import { Metric, Stats } from '../../aws-cloudwatch'; import * as cloudwatch from '../lib'; +it.each([ + Stats.percentileRank(0), + Stats.percentileRank(0, 1), + Stats.percentileRank(0, undefined), +])('Stats can create valid statistics %s without causing warnings', (statistic) => { + const metric = new Metric({ + namespace: 'example', + metricName: 'example', + statistic, + }); + + expect(metric.warningsV2).toEqual(undefined); +}); + test('spot check some constants', () => { expect(cloudwatch.Stats.AVERAGE).toEqual('Average'); expect(cloudwatch.Stats.IQM).toEqual('IQM');