From c8edc876bb1e2ea0fb63905021d9b4c77a913c9f Mon Sep 17 00:00:00 2001 From: Ahmed Kamel Date: Fri, 7 Jul 2023 21:17:55 +0100 Subject: [PATCH 1/3] feat(cloudwatch): allow configuring period on SingleValueWidget (#26260) - expose a period prop on `SingleValueWidgetProps` - use the period prop when rendering `SingleValueWidget` Closes #26259. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- ...singlevaluewidget-period-integ.assets.json | 19 +++ ...nglevaluewidget-period-integ.template.json | 55 +++++++ .../cdk.out | 1 + .../integ.json | 12 ++ .../manifest.json | 111 ++++++++++++++ ...efaultTestDeployAssert48DEBCE0.assets.json | 19 +++ ...aultTestDeployAssert48DEBCE0.template.json | 36 +++++ .../tree.json | 136 ++++++++++++++++++ ....period-singlevaluewidget-and-dashboard.ts | 28 ++++ packages/aws-cdk-lib/aws-cloudwatch/README.md | 12 ++ .../aws-cdk-lib/aws-cloudwatch/lib/graph.ts | 10 ++ .../aws-cloudwatch/test/graphs.test.ts | 28 ++++ 12 files changed, 467 insertions(+) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/aws-cdk-cloudwatch-singlevaluewidget-period-integ.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/aws-cdk-cloudwatch-singlevaluewidget-period-integ.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/tree.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/aws-cdk-cloudwatch-singlevaluewidget-period-integ.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/aws-cdk-cloudwatch-singlevaluewidget-period-integ.assets.json new file mode 100644 index 0000000000000..d263cc8b91a28 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/aws-cdk-cloudwatch-singlevaluewidget-period-integ.assets.json @@ -0,0 +1,19 @@ +{ + "version": "32.0.0", + "files": { + "d4dda261a18b29095c14be79773ff2c9cee39ed1fa347c6b46432c448eb55bfe": { + "source": { + "path": "aws-cdk-cloudwatch-singlevaluewidget-period-integ.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "d4dda261a18b29095c14be79773ff2c9cee39ed1fa347c6b46432c448eb55bfe.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/aws-cdk-cloudwatch-singlevaluewidget-period-integ.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/aws-cdk-cloudwatch-singlevaluewidget-period-integ.template.json new file mode 100644 index 0000000000000..97951783eced9 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/aws-cdk-cloudwatch-singlevaluewidget-period-integ.template.json @@ -0,0 +1,55 @@ +{ + "Resources": { + "Dashboard9E4231ED": { + "Type": "AWS::CloudWatch::Dashboard", + "Properties": { + "DashboardBody": { + "Fn::Join": [ + "", + [ + "{\"widgets\":[{\"type\":\"metric\",\"width\":6,\"height\":3,\"x\":0,\"y\":0,\"properties\":{\"view\":\"singleValue\",\"region\":\"", + { + "Ref": "AWS::Region" + }, + "\",\"metrics\":[[\"CDK/Test\",\"Metric\"]],\"period\":600}}]}" + ] + ] + } + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/cdk.out new file mode 100644 index 0000000000000..f0b901e7c06e5 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"32.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/integ.json new file mode 100644 index 0000000000000..3ebf220edecc8 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "32.0.0", + "testCases": { + "singlevaluewidget-with-period/DefaultTest": { + "stacks": [ + "aws-cdk-cloudwatch-singlevaluewidget-period-integ" + ], + "assertionStack": "singlevaluewidget-with-period/DefaultTest/DeployAssert", + "assertionStackName": "singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/manifest.json new file mode 100644 index 0000000000000..ffd6feb03a3dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/manifest.json @@ -0,0 +1,111 @@ +{ + "version": "32.0.0", + "artifacts": { + "aws-cdk-cloudwatch-singlevaluewidget-period-integ.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "aws-cdk-cloudwatch-singlevaluewidget-period-integ.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "aws-cdk-cloudwatch-singlevaluewidget-period-integ": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "aws-cdk-cloudwatch-singlevaluewidget-period-integ.template.json", + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/d4dda261a18b29095c14be79773ff2c9cee39ed1fa347c6b46432c448eb55bfe.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "aws-cdk-cloudwatch-singlevaluewidget-period-integ.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "aws-cdk-cloudwatch-singlevaluewidget-period-integ.assets" + ], + "metadata": { + "/aws-cdk-cloudwatch-singlevaluewidget-period-integ/Dashboard/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Dashboard9E4231ED" + } + ], + "/aws-cdk-cloudwatch-singlevaluewidget-period-integ/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-cdk-cloudwatch-singlevaluewidget-period-integ/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "aws-cdk-cloudwatch-singlevaluewidget-period-integ" + }, + "singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0.template.json", + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0.assets" + ], + "metadata": { + "/singlevaluewidget-with-period/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/singlevaluewidget-with-period/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "singlevaluewidget-with-period/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0.assets.json new file mode 100644 index 0000000000000..77843d5347a68 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0.assets.json @@ -0,0 +1,19 @@ +{ + "version": "32.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/singlevaluewidgetwithperiodDefaultTestDeployAssert48DEBCE0.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/tree.json new file mode 100644 index 0000000000000..bc0600913c3b3 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.js.snapshot/tree.json @@ -0,0 +1,136 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "aws-cdk-cloudwatch-singlevaluewidget-period-integ": { + "id": "aws-cdk-cloudwatch-singlevaluewidget-period-integ", + "path": "aws-cdk-cloudwatch-singlevaluewidget-period-integ", + "children": { + "Dashboard": { + "id": "Dashboard", + "path": "aws-cdk-cloudwatch-singlevaluewidget-period-integ/Dashboard", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-cdk-cloudwatch-singlevaluewidget-period-integ/Dashboard/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CloudWatch::Dashboard", + "aws:cdk:cloudformation:props": { + "dashboardBody": { + "Fn::Join": [ + "", + [ + "{\"widgets\":[{\"type\":\"metric\",\"width\":6,\"height\":3,\"x\":0,\"y\":0,\"properties\":{\"view\":\"singleValue\",\"region\":\"", + { + "Ref": "AWS::Region" + }, + "\",\"metrics\":[[\"CDK/Test\",\"Metric\"]],\"period\":600}}]}" + ] + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudwatch.CfnDashboard", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudwatch.Dashboard", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "aws-cdk-cloudwatch-singlevaluewidget-period-integ/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "aws-cdk-cloudwatch-singlevaluewidget-period-integ/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "singlevaluewidget-with-period": { + "id": "singlevaluewidget-with-period", + "path": "singlevaluewidget-with-period", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "singlevaluewidget-with-period/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "singlevaluewidget-with-period/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.55" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "singlevaluewidget-with-period/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "singlevaluewidget-with-period/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "singlevaluewidget-with-period/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.55" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.ts new file mode 100644 index 0000000000000..61c2b8808a889 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.period-singlevaluewidget-and-dashboard.ts @@ -0,0 +1,28 @@ +import { App, Duration, Stack, StackProps } from 'aws-cdk-lib'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; +import { Dashboard, SingleValueWidget, Metric } from 'aws-cdk-lib/aws-cloudwatch'; + +class TestStack extends Stack { + constructor(scope: App, id: string, props?: StackProps) { + super(scope, id, props); + + const dashboard = new Dashboard(this, 'Dashboard'); + + const testMetric = new Metric({ + namespace: 'CDK/Test', + metricName: 'Metric', + }); + + const widget = new SingleValueWidget({ + metrics: [testMetric], + period: Duration.minutes(10), + }); + + dashboard.addWidgets(widget); + } +} +const app = new App(); +const testCase = new TestStack(app, 'aws-cdk-cloudwatch-singlevaluewidget-period-integ'); +new IntegTest(app, 'singlevaluewidget-with-period', { + testCases: [testCase], +}); diff --git a/packages/aws-cdk-lib/aws-cloudwatch/README.md b/packages/aws-cdk-lib/aws-cloudwatch/README.md index c01213a90d6f1..bf28003b05a7d 100644 --- a/packages/aws-cdk-lib/aws-cloudwatch/README.md +++ b/packages/aws-cdk-lib/aws-cloudwatch/README.md @@ -544,6 +544,18 @@ dashboard.addWidgets(new cloudwatch.SingleValueWidget({ })); ``` +Period allows you to set the default period for the widget: + +```ts +declare const dashboard: cloudwatch.Dashboard; + +dashboard.addWidgets(new cloudwatch.SingleValueWidget({ + metrics: [ /* ... */ ], + + period: Duration.minutes(15), +})); +``` + ### Text widget A text widget shows an arbitrary piece of MarkDown. Use this to add explanations diff --git a/packages/aws-cdk-lib/aws-cloudwatch/lib/graph.ts b/packages/aws-cdk-lib/aws-cloudwatch/lib/graph.ts index 591655941b2d2..c7b5c7d497a34 100644 --- a/packages/aws-cdk-lib/aws-cloudwatch/lib/graph.ts +++ b/packages/aws-cdk-lib/aws-cloudwatch/lib/graph.ts @@ -451,6 +451,15 @@ export interface SingleValueWidgetProps extends MetricWidgetProps { */ readonly metrics: IMetric[]; + /** + * The default period for all metrics in this widget. + * The period is the length of time represented by one data point on the graph. + * This default can be overridden within each metric definition. + * + * @default cdk.Duration.seconds(300) + */ + readonly period?: cdk.Duration; + /** * Whether to show the value from the entire time range. * @@ -505,6 +514,7 @@ export class SingleValueWidget extends ConcreteWidget { metrics: allMetricsGraphJson(this.props.metrics, []), setPeriodToTimeRange: this.props.setPeriodToTimeRange, singleValueFullPrecision: this.props.fullPrecision, + period: this.props.period?.toSeconds(), }, }]; } diff --git a/packages/aws-cdk-lib/aws-cloudwatch/test/graphs.test.ts b/packages/aws-cdk-lib/aws-cloudwatch/test/graphs.test.ts index 3d8d32c668f39..fc440f1c416b9 100644 --- a/packages/aws-cdk-lib/aws-cloudwatch/test/graphs.test.ts +++ b/packages/aws-cdk-lib/aws-cloudwatch/test/graphs.test.ts @@ -677,6 +677,34 @@ describe('Graphs', () => { }); + test('add period to singleValueWidget', () => { + // GIVEN + const stack = new Stack(); + const metric = new Metric({ namespace: 'CDK', metricName: 'Test' }); + + // WHEN + const widget = new SingleValueWidget({ + metrics: [metric], + period: Duration.days(2), + }); + + // THEN + expect(stack.resolve(widget.toJson())).toEqual([{ + type: 'metric', + width: 6, + height: 3, + properties: { + view: 'singleValue', + region: { Ref: 'AWS::Region' }, + metrics: [ + ['CDK', 'Test'], + ], + period: 172800, + }, + }]); + + }); + test('allows overriding custom values of dashboard widgets', () => { class HiddenMetric extends Metric { public toMetricConfig() { From f9a11922fe4d5a85e646eb51ed7d4c8a013b53b1 Mon Sep 17 00:00:00 2001 From: clueleaf <10379303+clueleaf@users.noreply.github.com> Date: Mon, 10 Jul 2023 19:10:50 +0900 Subject: [PATCH 2/3] chore(ec2): replace latestAmazonLinux with latestAmazonLinux2 used inside BastionHostLinux (#26134) Synthesizing `BastionHostLinux` generates the following warning: ``` [WARNING] aws-cdk-lib.aws_ec2.MachineImage#latestAmazonLinux is deprecated. use MachineImage.latestAmazonLinux2 instead This API will be removed in the next major release. ``` This PR replaces `latestAmazonLinux` used inside `BastionHostLinux` with `latestAmazonLinux2` to remove the warning. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../TestStack.assets.json | 6 +- .../TestStack.template.json | 6 +- .../cdk.out | 2 +- .../integ.json | 2 +- .../manifest.json | 25 +-- .../tree.json | 148 ++++++++++-------- .../aws-cdk-lib/aws-ec2/lib/bastion-host.ts | 5 +- .../aws-ec2/test/bastion-host.test.ts | 4 +- 8 files changed, 112 insertions(+), 86 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/TestStack.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/TestStack.assets.json index bbc121074bff7..6610b684a4713 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/TestStack.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/TestStack.assets.json @@ -1,7 +1,7 @@ { - "version": "21.0.0", + "version": "32.0.0", "files": { - "d9d2cb111f211504d3d3b1b90cf33d2a124047f2b2621f6b695851e1226d322a": { + "a199e8eb329a5d9963b37d63e0ed1df710a2d45d2f208f121329f7325f8a4861": { "source": { "path": "TestStack.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "d9d2cb111f211504d3d3b1b90cf33d2a124047f2b2621f6b695851e1226d322a.json", + "objectKey": "a199e8eb329a5d9963b37d63e0ed1df710a2d45d2f208f121329f7325f8a4861.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/TestStack.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/TestStack.template.json index 92a4bdbff0794..256e9531148e4 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/TestStack.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/TestStack.template.json @@ -486,7 +486,7 @@ "Ref": "BastionHostInstanceProfile770FCA07" }, "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmarm64gp2C96584B6F00A464EAD1953AFF4B05118Parameter" + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amikernel510hvmarm64gp2C96584B6F00A464EAD1953AFF4B05118Parameter" }, "InstanceType": "t4g.nano", "SecurityGroupIds": [ @@ -525,9 +525,9 @@ } }, "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmarm64gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { + "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amikernel510hvmarm64gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-arm64-gp2" + "Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-kernel-5.10-hvm-arm64-gp2" }, "BootstrapVersion": { "Type": "AWS::SSM::Parameter::Value", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/cdk.out index 588d7b269d34f..f0b901e7c06e5 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/cdk.out +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"20.0.0"} \ No newline at end of file +{"version":"32.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/integ.json index fcd213022a674..fd5008ee4eb4c 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/integ.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "21.0.0", + "version": "32.0.0", "testCases": { "integ.bastion-host-arm-support": { "stacks": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/manifest.json index 550739dd5e6ca..3a52c910acc6c 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/manifest.json @@ -1,12 +1,6 @@ { - "version": "21.0.0", + "version": "32.0.0", "artifacts": { - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } - }, "TestStack.assets": { "type": "cdk:asset-manifest", "properties": { @@ -23,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/d9d2cb111f211504d3d3b1b90cf33d2a124047f2b2621f6b695851e1226d322a.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/a199e8eb329a5d9963b37d63e0ed1df710a2d45d2f208f121329f7325f8a4861.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -204,7 +198,10 @@ "/TestStack/BastionHost/Resource/Resource": [ { "type": "aws:cdk:logicalId", - "data": "BastionHost30F9ED05" + "data": "BastionHost30F9ED05", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_REPLACE" + ] } ], "/TestStack/BastionHost/BastionHostId": [ @@ -213,10 +210,10 @@ "data": "BastionHostBastionHostIdC743CBD6" } ], - "/TestStack/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-hvm-arm64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": [ + "/TestStack/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-kernel-5.10-hvm-arm64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": [ { "type": "aws:cdk:logicalId", - "data": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmarm64gp2C96584B6F00A464EAD1953AFF4B05118Parameter" + "data": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amikernel510hvmarm64gp2C96584B6F00A464EAD1953AFF4B05118Parameter" } ], "/TestStack/BootstrapVersion": [ @@ -233,6 +230,12 @@ ] }, "displayName": "TestStack" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } } } } \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/tree.json index 14da7c46d3217..3eb98f271b373 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.js.snapshot/tree.json @@ -4,14 +4,6 @@ "id": "App", "path": "", "children": { - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.123" - } - }, "TestStack": { "id": "TestStack", "path": "TestStack", @@ -39,7 +31,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnVPC", + "fqn": "aws-cdk-lib.aws_ec2.CfnVPC", "version": "0.0.0" } }, @@ -83,7 +75,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", "version": "0.0.0" } }, @@ -91,7 +83,7 @@ "id": "Acl", "path": "TestStack/VPC/PublicSubnet1/Acl", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -113,7 +105,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", "version": "0.0.0" } }, @@ -132,7 +124,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", "version": "0.0.0" } }, @@ -152,7 +144,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", "version": "0.0.0" } }, @@ -172,7 +164,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnEIP", + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", "version": "0.0.0" } }, @@ -200,13 +192,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnNatGateway", + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.PublicSubnet", + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", "version": "0.0.0" } }, @@ -250,7 +242,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", "version": "0.0.0" } }, @@ -258,7 +250,7 @@ "id": "Acl", "path": "TestStack/VPC/PublicSubnet2/Acl", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -280,7 +272,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", "version": "0.0.0" } }, @@ -299,7 +291,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", "version": "0.0.0" } }, @@ -319,7 +311,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", "version": "0.0.0" } }, @@ -339,7 +331,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnEIP", + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", "version": "0.0.0" } }, @@ -367,13 +359,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnNatGateway", + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.PublicSubnet", + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", "version": "0.0.0" } }, @@ -417,7 +409,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", "version": "0.0.0" } }, @@ -425,7 +417,7 @@ "id": "Acl", "path": "TestStack/VPC/PrivateSubnet1/Acl", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -447,7 +439,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", "version": "0.0.0" } }, @@ -466,7 +458,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", "version": "0.0.0" } }, @@ -486,13 +478,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.PrivateSubnet", + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", "version": "0.0.0" } }, @@ -536,7 +528,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", "version": "0.0.0" } }, @@ -544,7 +536,7 @@ "id": "Acl", "path": "TestStack/VPC/PrivateSubnet2/Acl", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -566,7 +558,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", "version": "0.0.0" } }, @@ -585,7 +577,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", "version": "0.0.0" } }, @@ -605,13 +597,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.PrivateSubnet", + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", "version": "0.0.0" } }, @@ -630,7 +622,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnInternetGateway", + "fqn": "aws-cdk-lib.aws_ec2.CfnInternetGateway", "version": "0.0.0" } }, @@ -649,13 +641,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnVPCGatewayAttachment", + "fqn": "aws-cdk-lib.aws_ec2.CfnVPCGatewayAttachment", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.Vpc", + "fqn": "aws-cdk-lib.aws_ec2.Vpc", "version": "0.0.0" } }, @@ -697,13 +689,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSecurityGroup", + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroup", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.SecurityGroup", + "fqn": "aws-cdk-lib.aws_ec2.SecurityGroup", "version": "0.0.0" } }, @@ -711,6 +703,14 @@ "id": "InstanceRole", "path": "TestStack/BastionHost/Resource/InstanceRole", "children": { + "ImportInstanceRole": { + "id": "ImportInstanceRole", + "path": "TestStack/BastionHost/Resource/InstanceRole/ImportInstanceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "TestStack/BastionHost/Resource/InstanceRole/Resource", @@ -738,7 +738,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", + "fqn": "aws-cdk-lib.aws_iam.CfnRole", "version": "0.0.0" } }, @@ -775,19 +775,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnPolicy", + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Policy", + "fqn": "aws-cdk-lib.aws_iam.Policy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", + "fqn": "aws-cdk-lib.aws_iam.Role", "version": "0.0.0" } }, @@ -805,7 +805,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnInstanceProfile", + "fqn": "aws-cdk-lib.aws_iam.CfnInstanceProfile", "version": "0.0.0" } }, @@ -827,7 +827,7 @@ "Ref": "BastionHostInstanceProfile770FCA07" }, "imageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmarm64gp2C96584B6F00A464EAD1953AFF4B05118Parameter" + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amikernel510hvmarm64gp2C96584B6F00A464EAD1953AFF4B05118Parameter" }, "instanceType": "t4g.nano", "securityGroupIds": [ @@ -853,13 +853,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnInstance", + "fqn": "aws-cdk-lib.aws_ec2.CfnInstance", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.Instance", + "fqn": "aws-cdk-lib.aws_ec2.Instance", "version": "0.0.0" } }, @@ -867,41 +867,65 @@ "id": "BastionHostId", "path": "TestStack/BastionHost/BastionHostId", "constructInfo": { - "fqn": "@aws-cdk/core.CfnOutput", + "fqn": "aws-cdk-lib.CfnOutput", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.BastionHostLinux", + "fqn": "aws-cdk-lib.aws_ec2.BastionHostLinux", + "version": "0.0.0" + } + }, + "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-kernel-5.10-hvm-arm64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": { + "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-kernel-5.10-hvm-arm64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", + "path": "TestStack/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-kernel-5.10-hvm-arm64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", "version": "0.0.0" } }, - "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-hvm-arm64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": { - "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-hvm-arm64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", - "path": "TestStack/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-hvm-arm64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", + "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-kernel-5.10-hvm-arm64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118": { + "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-kernel-5.10-hvm-arm64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118", + "path": "TestStack/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-kernel-5.10-hvm-arm64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118", "constructInfo": { - "fqn": "@aws-cdk/core.CfnParameter", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, - "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-hvm-arm64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118": { - "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-hvm-arm64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118", - "path": "TestStack/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-hvm-arm64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118", + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "TestStack/BootstrapVersion", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "TestStack/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/core.Stack", + "fqn": "aws-cdk-lib.Stack", "version": "0.0.0" } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.55" + } } }, "constructInfo": { - "fqn": "@aws-cdk/core.App", + "fqn": "aws-cdk-lib.App", "version": "0.0.0" } } diff --git a/packages/aws-cdk-lib/aws-ec2/lib/bastion-host.ts b/packages/aws-cdk-lib/aws-ec2/lib/bastion-host.ts index b65f9762c6c4a..7671aa03aa489 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/bastion-host.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/bastion-host.ts @@ -1,5 +1,5 @@ import { Construct } from 'constructs'; -import { AmazonLinuxGeneration, InstanceArchitecture, InstanceClass, InstanceSize, InstanceType } from '.'; +import { InstanceArchitecture, InstanceClass, InstanceSize, InstanceType } from '.'; import { CloudFormationInit } from './cfn-init'; import { Connections } from './connections'; import { ApplyCloudFormationInitOptions, IInstance, Instance } from './instance'; @@ -180,8 +180,7 @@ export class BastionHostLinux extends Resource implements IInstance { securityGroup: props.securityGroup, instanceName: props.instanceName ?? 'BastionHost', instanceType, - machineImage: props.machineImage ?? MachineImage.latestAmazonLinux({ - generation: AmazonLinuxGeneration.AMAZON_LINUX_2, + machineImage: props.machineImage ?? MachineImage.latestAmazonLinux2({ cpuType: this.toAmazonLinuxCpuType(instanceType.architecture), }), vpcSubnets: props.subnetSelection ?? {}, diff --git a/packages/aws-cdk-lib/aws-ec2/test/bastion-host.test.ts b/packages/aws-cdk-lib/aws-ec2/test/bastion-host.test.ts index 51f9faff2ef41..39445e894e1a1 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/bastion-host.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/bastion-host.test.ts @@ -94,7 +94,7 @@ describe('bastion host', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::EC2::Instance', { ImageId: { - Ref: 'SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter', + Ref: 'SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amikernel510hvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter', }, }); @@ -113,7 +113,7 @@ describe('bastion host', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::EC2::Instance', { ImageId: { - Ref: 'SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmarm64gp2C96584B6F00A464EAD1953AFF4B05118Parameter', + Ref: 'SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amikernel510hvmarm64gp2C96584B6F00A464EAD1953AFF4B05118Parameter', }, }); From bd06669586baee054f1a9a6bb142d572d21ce3bc Mon Sep 17 00:00:00 2001 From: Randy Ridgley Date: Mon, 10 Jul 2023 06:38:37 -0400 Subject: [PATCH 3/3] fix(lambda): add instrument handler option to adotInstrumentation to support python lambda functions (#26040) Small change to add an enum value to AdotLambdaExecWrapper. The python layer for adot requires the path *'/opt/otel-instrument'* which differs from the layer needed for other languages which is *'/opt/otel-handler'*. In the link below in the section **Enable auto-instrumentation for your Lambda function** step 5 requires the *'/opt/otel-instrument'* path. The existing work around is to provide a lambda layer yourself and the appropriate env variable for *AWS_LAMBDA_EXEC_WRAPPER* without using the adotInstrumentation parameters. This fix simplifies dev requirements. [Python Lambda Otel](https://aws-otel.github.io/docs/getting-started/lambda/lambda-python) Closes #24666. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- ...efaultTestDeployAssertE3E7D2A4.assets.json | 2 +- .../Stack1.assets.json | 6 +- .../Stack1.template.json | 8 +- .../Stack2.assets.json | 6 +- .../Stack2.template.json | 8 +- .../integ.lambda-adot.js.snapshot/cdk.out | 2 +- .../integ.lambda-adot.js.snapshot/integ.json | 2 +- .../manifest.json | 60 ++- .../integ.lambda-adot.js.snapshot/tree.json | 346 +++++++++--------- .../test/aws-lambda/test/integ.lambda-adot.ts | 8 +- packages/aws-cdk-lib/aws-lambda/README.md | 2 + .../aws-cdk-lib/aws-lambda/lib/adot-layers.ts | 5 + .../aws-cdk-lib/aws-lambda/lib/function.ts | 10 +- .../aws-lambda/test/function.test.ts | 43 +++ 14 files changed, 309 insertions(+), 199 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/IntegTestDefaultTestDeployAssertE3E7D2A4.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/IntegTestDefaultTestDeployAssertE3E7D2A4.assets.json index ab8ca0bd4a1f2..1e34ca625f5ac 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/IntegTestDefaultTestDeployAssertE3E7D2A4.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/IntegTestDefaultTestDeployAssertE3E7D2A4.assets.json @@ -1,5 +1,5 @@ { - "version": "22.0.0", + "version": "32.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack1.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack1.assets.json index a0e1449cea6ee..7c4a95ce08042 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack1.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack1.assets.json @@ -1,7 +1,7 @@ { - "version": "22.0.0", + "version": "32.0.0", "files": { - "47696196003068eea2528656bebb8f11e163f75e8635d774b801bbc06a0e57e2": { + "da818761c778b9099af670b7379d3db67a8f46572795cf76cc3f7442b341fb86": { "source": { "path": "Stack1.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "47696196003068eea2528656bebb8f11e163f75e8635d774b801bbc06a0e57e2.json", + "objectKey": "da818761c778b9099af670b7379d3db67a8f46572795cf76cc3f7442b341fb86.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack1.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack1.template.json index 7c14bc7d09da1..c9b23bd17ce83 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack1.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack1.template.json @@ -166,7 +166,7 @@ }, "Environment": { "Variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "Handler": "index.handler", @@ -263,7 +263,7 @@ }, "Environment": { "Variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "Handler": "index.handler", @@ -360,7 +360,7 @@ }, "Environment": { "Variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "Handler": "index.handler", @@ -457,7 +457,7 @@ }, "Environment": { "Variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "Handler": "index.handler", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack2.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack2.assets.json index 48c0af9610b9d..6752713291eea 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack2.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack2.assets.json @@ -1,7 +1,7 @@ { - "version": "22.0.0", + "version": "32.0.0", "files": { - "a4926065bd63dad984b7b214cd689e14b56eeec5afba89f078cd5134f8304bd8": { + "a4d1f60a1bf3af6d4d630d5c0557444ee8d18f93483887409a89dc8f34b228d5": { "source": { "path": "Stack2.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "a4926065bd63dad984b7b214cd689e14b56eeec5afba89f078cd5134f8304bd8.json", + "objectKey": "a4d1f60a1bf3af6d4d630d5c0557444ee8d18f93483887409a89dc8f34b228d5.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack2.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack2.template.json index d268d79b5f964..ebcf7448ac457 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack2.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack2.template.json @@ -169,7 +169,7 @@ }, "Environment": { "Variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "Handler": "index.handler", @@ -266,7 +266,7 @@ }, "Environment": { "Variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "Handler": "index.handler", @@ -363,7 +363,7 @@ }, "Environment": { "Variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "Handler": "index.handler", @@ -460,7 +460,7 @@ }, "Environment": { "Variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "Handler": "index.handler", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/cdk.out index 145739f539580..f0b901e7c06e5 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/cdk.out +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"22.0.0"} \ No newline at end of file +{"version":"32.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/integ.json index 48b2c710d1101..263e489ed7e1c 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/integ.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "22.0.0", + "version": "32.0.0", "testCases": { "IntegTest/DefaultTest": { "stacks": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/manifest.json index 0c1767cb8ed9c..ea4102575a0a7 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "22.0.0", + "version": "32.0.0", "artifacts": { "Stack1.assets": { "type": "cdk:asset-manifest", @@ -17,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/47696196003068eea2528656bebb8f11e163f75e8635d774b801bbc06a0e57e2.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/da818761c778b9099af670b7379d3db67a8f46572795cf76cc3f7442b341fb86.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -140,6 +140,33 @@ "type": "aws:cdk:logicalId", "data": "CheckBootstrapVersion" } + ], + "MyFunc6ServiceRoleCDDBC2C6": [ + { + "type": "aws:cdk:logicalId", + "data": "MyFunc6ServiceRoleCDDBC2C6", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "MyFunc6ServiceRoleDefaultPolicyC4D4BF55": [ + { + "type": "aws:cdk:logicalId", + "data": "MyFunc6ServiceRoleDefaultPolicyC4D4BF55", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "MyFunc60D944984": [ + { + "type": "aws:cdk:logicalId", + "data": "MyFunc60D944984", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } ] }, "displayName": "Stack1" @@ -160,7 +187,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/a4926065bd63dad984b7b214cd689e14b56eeec5afba89f078cd5134f8304bd8.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/a4d1f60a1bf3af6d4d630d5c0557444ee8d18f93483887409a89dc8f34b228d5.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -277,6 +304,33 @@ "type": "aws:cdk:logicalId", "data": "CheckBootstrapVersion" } + ], + "MyFunc6ServiceRoleCDDBC2C6": [ + { + "type": "aws:cdk:logicalId", + "data": "MyFunc6ServiceRoleCDDBC2C6", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "MyFunc6ServiceRoleDefaultPolicyC4D4BF55": [ + { + "type": "aws:cdk:logicalId", + "data": "MyFunc6ServiceRoleDefaultPolicyC4D4BF55", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "MyFunc60D944984": [ + { + "type": "aws:cdk:logicalId", + "data": "MyFunc60D944984", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } ] }, "displayName": "Stack2" diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/tree.json index 9f2eb419a99ba..5db219ef20619 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/tree.json @@ -20,7 +20,7 @@ "id": "ImportServiceRole", "path": "Stack1/MyFunc1/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -59,7 +59,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", + "fqn": "aws-cdk-lib.aws_iam.CfnRole", "version": "0.0.0" } }, @@ -95,19 +95,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnPolicy", + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Policy", + "fqn": "aws-cdk-lib.aws_iam.Policy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", + "fqn": "aws-cdk-lib.aws_iam.Role", "version": "0.0.0" } }, @@ -153,13 +153,21 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "AdotLayer": { + "id": "AdotLayer", + "path": "Stack1/MyFunc1/AdotLayer", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", + "fqn": "aws-cdk-lib.aws_lambda.FunctionBase", "version": "0.0.0" } }, @@ -167,15 +175,7 @@ "id": "Adot-lambda-layerMap", "path": "Stack1/Adot-lambda-layerMap", "constructInfo": { - "fqn": "@aws-cdk/core.CfnMapping", - "version": "0.0.0" - } - }, - "AdotLayer1": { - "id": "AdotLayer1", - "path": "Stack1/AdotLayer1", - "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.CfnMapping", "version": "0.0.0" } }, @@ -191,7 +191,7 @@ "id": "ImportServiceRole", "path": "Stack1/MyFunc2/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -230,7 +230,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", + "fqn": "aws-cdk-lib.aws_iam.CfnRole", "version": "0.0.0" } }, @@ -266,19 +266,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnPolicy", + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Policy", + "fqn": "aws-cdk-lib.aws_iam.Policy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", + "fqn": "aws-cdk-lib.aws_iam.Role", "version": "0.0.0" } }, @@ -299,7 +299,7 @@ }, "environment": { "variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "handler": "index.handler", @@ -324,21 +324,21 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "AdotLayer": { + "id": "AdotLayer", + "path": "Stack1/MyFunc2/AdotLayer", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - }, - "AdotLayer2": { - "id": "AdotLayer2", - "path": "Stack1/AdotLayer2", - "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.aws_lambda.FunctionBase", "version": "0.0.0" } }, @@ -354,7 +354,7 @@ "id": "ImportServiceRole", "path": "Stack1/MyFunc3/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -393,7 +393,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", + "fqn": "aws-cdk-lib.aws_iam.CfnRole", "version": "0.0.0" } }, @@ -429,19 +429,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnPolicy", + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Policy", + "fqn": "aws-cdk-lib.aws_iam.Policy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", + "fqn": "aws-cdk-lib.aws_iam.Role", "version": "0.0.0" } }, @@ -462,7 +462,7 @@ }, "environment": { "variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "handler": "index.handler", @@ -487,21 +487,21 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "AdotLayer": { + "id": "AdotLayer", + "path": "Stack1/MyFunc3/AdotLayer", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - }, - "AdotLayer3": { - "id": "AdotLayer3", - "path": "Stack1/AdotLayer3", - "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.aws_lambda.FunctionBase", "version": "0.0.0" } }, @@ -517,7 +517,7 @@ "id": "ImportServiceRole", "path": "Stack1/MyFunc4/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -556,7 +556,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", + "fqn": "aws-cdk-lib.aws_iam.CfnRole", "version": "0.0.0" } }, @@ -592,19 +592,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnPolicy", + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Policy", + "fqn": "aws-cdk-lib.aws_iam.Policy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", + "fqn": "aws-cdk-lib.aws_iam.Role", "version": "0.0.0" } }, @@ -625,7 +625,7 @@ }, "environment": { "variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "handler": "index.handler", @@ -650,21 +650,21 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "AdotLayer": { + "id": "AdotLayer", + "path": "Stack1/MyFunc4/AdotLayer", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - }, - "AdotLayer4": { - "id": "AdotLayer4", - "path": "Stack1/AdotLayer4", - "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.aws_lambda.FunctionBase", "version": "0.0.0" } }, @@ -680,7 +680,7 @@ "id": "ImportServiceRole", "path": "Stack1/MyFunc5/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -719,7 +719,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", + "fqn": "aws-cdk-lib.aws_iam.CfnRole", "version": "0.0.0" } }, @@ -755,19 +755,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnPolicy", + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Policy", + "fqn": "aws-cdk-lib.aws_iam.Policy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", + "fqn": "aws-cdk-lib.aws_iam.Role", "version": "0.0.0" } }, @@ -788,7 +788,7 @@ }, "environment": { "variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "handler": "index.handler", @@ -813,21 +813,21 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "AdotLayer": { + "id": "AdotLayer", + "path": "Stack1/MyFunc5/AdotLayer", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - }, - "AdotLayer5": { - "id": "AdotLayer5", - "path": "Stack1/AdotLayer5", - "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.aws_lambda.FunctionBase", "version": "0.0.0" } }, @@ -835,7 +835,7 @@ "id": "BootstrapVersion", "path": "Stack1/BootstrapVersion", "constructInfo": { - "fqn": "@aws-cdk/core.CfnParameter", + "fqn": "aws-cdk-lib.CfnParameter", "version": "0.0.0" } }, @@ -843,13 +843,13 @@ "id": "CheckBootstrapVersion", "path": "Stack1/CheckBootstrapVersion", "constructInfo": { - "fqn": "@aws-cdk/core.CfnRule", + "fqn": "aws-cdk-lib.CfnRule", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/core.Stack", + "fqn": "aws-cdk-lib.Stack", "version": "0.0.0" } }, @@ -869,7 +869,7 @@ "id": "ImportServiceRole", "path": "Stack2/MyFunc1/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -908,7 +908,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", + "fqn": "aws-cdk-lib.aws_iam.CfnRole", "version": "0.0.0" } }, @@ -944,19 +944,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnPolicy", + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Policy", + "fqn": "aws-cdk-lib.aws_iam.Policy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", + "fqn": "aws-cdk-lib.aws_iam.Role", "version": "0.0.0" } }, @@ -1005,21 +1005,21 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "AdotLayer": { + "id": "AdotLayer", + "path": "Stack2/MyFunc1/AdotLayer", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - }, - "AdotLayer1": { - "id": "AdotLayer1", - "path": "Stack2/AdotLayer1", - "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.aws_lambda.FunctionBase", "version": "0.0.0" } }, @@ -1035,7 +1035,7 @@ "id": "ImportServiceRole", "path": "Stack2/MyFunc2/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -1074,7 +1074,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", + "fqn": "aws-cdk-lib.aws_iam.CfnRole", "version": "0.0.0" } }, @@ -1110,19 +1110,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnPolicy", + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Policy", + "fqn": "aws-cdk-lib.aws_iam.Policy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", + "fqn": "aws-cdk-lib.aws_iam.Role", "version": "0.0.0" } }, @@ -1143,7 +1143,7 @@ }, "environment": { "variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "handler": "index.handler", @@ -1168,21 +1168,21 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "AdotLayer": { + "id": "AdotLayer", + "path": "Stack2/MyFunc2/AdotLayer", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - }, - "AdotLayer2": { - "id": "AdotLayer2", - "path": "Stack2/AdotLayer2", - "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.aws_lambda.FunctionBase", "version": "0.0.0" } }, @@ -1198,7 +1198,7 @@ "id": "ImportServiceRole", "path": "Stack2/MyFunc3/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -1237,7 +1237,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", + "fqn": "aws-cdk-lib.aws_iam.CfnRole", "version": "0.0.0" } }, @@ -1273,19 +1273,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnPolicy", + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Policy", + "fqn": "aws-cdk-lib.aws_iam.Policy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", + "fqn": "aws-cdk-lib.aws_iam.Role", "version": "0.0.0" } }, @@ -1306,7 +1306,7 @@ }, "environment": { "variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "handler": "index.handler", @@ -1331,21 +1331,21 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "AdotLayer": { + "id": "AdotLayer", + "path": "Stack2/MyFunc3/AdotLayer", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - }, - "AdotLayer3": { - "id": "AdotLayer3", - "path": "Stack2/AdotLayer3", - "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.aws_lambda.FunctionBase", "version": "0.0.0" } }, @@ -1361,7 +1361,7 @@ "id": "ImportServiceRole", "path": "Stack2/MyFunc4/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -1400,7 +1400,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", + "fqn": "aws-cdk-lib.aws_iam.CfnRole", "version": "0.0.0" } }, @@ -1436,19 +1436,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnPolicy", + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Policy", + "fqn": "aws-cdk-lib.aws_iam.Policy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", + "fqn": "aws-cdk-lib.aws_iam.Role", "version": "0.0.0" } }, @@ -1469,7 +1469,7 @@ }, "environment": { "variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "handler": "index.handler", @@ -1494,21 +1494,21 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "AdotLayer": { + "id": "AdotLayer", + "path": "Stack2/MyFunc4/AdotLayer", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - }, - "AdotLayer4": { - "id": "AdotLayer4", - "path": "Stack2/AdotLayer4", - "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.aws_lambda.FunctionBase", "version": "0.0.0" } }, @@ -1524,7 +1524,7 @@ "id": "ImportServiceRole", "path": "Stack2/MyFunc5/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -1563,7 +1563,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", + "fqn": "aws-cdk-lib.aws_iam.CfnRole", "version": "0.0.0" } }, @@ -1599,19 +1599,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnPolicy", + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Policy", + "fqn": "aws-cdk-lib.aws_iam.Policy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", + "fqn": "aws-cdk-lib.aws_iam.Role", "version": "0.0.0" } }, @@ -1632,7 +1632,7 @@ }, "environment": { "variables": { - "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler" + "AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument" } }, "handler": "index.handler", @@ -1657,21 +1657,21 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "AdotLayer": { + "id": "AdotLayer", + "path": "Stack2/MyFunc5/AdotLayer", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - }, - "AdotLayer5": { - "id": "AdotLayer5", - "path": "Stack2/AdotLayer5", - "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.aws_lambda.FunctionBase", "version": "0.0.0" } }, @@ -1679,7 +1679,7 @@ "id": "BootstrapVersion", "path": "Stack2/BootstrapVersion", "constructInfo": { - "fqn": "@aws-cdk/core.CfnParameter", + "fqn": "aws-cdk-lib.CfnParameter", "version": "0.0.0" } }, @@ -1687,13 +1687,13 @@ "id": "CheckBootstrapVersion", "path": "Stack2/CheckBootstrapVersion", "constructInfo": { - "fqn": "@aws-cdk/core.CfnRule", + "fqn": "aws-cdk-lib.CfnRule", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/core.Stack", + "fqn": "aws-cdk-lib.Stack", "version": "0.0.0" } }, @@ -1710,7 +1710,7 @@ "path": "IntegTest/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.168" + "version": "10.2.55" } }, "DeployAssert": { @@ -1721,7 +1721,7 @@ "id": "BootstrapVersion", "path": "IntegTest/DefaultTest/DeployAssert/BootstrapVersion", "constructInfo": { - "fqn": "@aws-cdk/core.CfnParameter", + "fqn": "aws-cdk-lib.CfnParameter", "version": "0.0.0" } }, @@ -1729,25 +1729,25 @@ "id": "CheckBootstrapVersion", "path": "IntegTest/DefaultTest/DeployAssert/CheckBootstrapVersion", "constructInfo": { - "fqn": "@aws-cdk/core.CfnRule", + "fqn": "aws-cdk-lib.CfnRule", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/core.Stack", + "fqn": "aws-cdk-lib.Stack", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/integ-tests.IntegTestCase", + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/integ-tests.IntegTest", + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", "version": "0.0.0" } }, @@ -1756,12 +1756,12 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.168" + "version": "10.2.55" } } }, "constructInfo": { - "fqn": "@aws-cdk/core.App", + "fqn": "aws-cdk-lib.App", "version": "0.0.0" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.ts index f5a8e1839bd8c..07c6e6f1e74f2 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.ts @@ -43,7 +43,7 @@ class StackUnderTest extends Stack { code: Code.fromInline('def handler(event, context): pass'), adotInstrumentation: { layerVersion: AdotLayerVersion.fromPythonSdkLayerVersion(AdotLambdaLayerPythonSdkVersion.LATEST), - execWrapper: AdotLambdaExecWrapper.REGULAR_HANDLER, + execWrapper: AdotLambdaExecWrapper.INSTRUMENT_HANDLER, }, }); @@ -53,7 +53,7 @@ class StackUnderTest extends Stack { code: Code.fromInline('def handler(event, context): pass'), adotInstrumentation: { layerVersion: AdotLayerVersion.fromJavaSdkLayerVersion(AdotLambdaLayerJavaSdkVersion.LATEST), - execWrapper: AdotLambdaExecWrapper.REGULAR_HANDLER, + execWrapper: AdotLambdaExecWrapper.INSTRUMENT_HANDLER, }, }); @@ -63,7 +63,7 @@ class StackUnderTest extends Stack { code: Code.fromInline('def handler(event, context): pass'), adotInstrumentation: { layerVersion: AdotLayerVersion.fromJavaAutoInstrumentationLayerVersion(AdotLambdaLayerJavaAutoInstrumentationVersion.LATEST), - execWrapper: AdotLambdaExecWrapper.REGULAR_HANDLER, + execWrapper: AdotLambdaExecWrapper.INSTRUMENT_HANDLER, }, }); @@ -73,7 +73,7 @@ class StackUnderTest extends Stack { code: Code.fromInline('def handler(event, context): pass'), adotInstrumentation: { layerVersion: AdotLayerVersion.fromGenericLayerVersion(AdotLambdaLayerGenericVersion.LATEST), - execWrapper: AdotLambdaExecWrapper.REGULAR_HANDLER, + execWrapper: AdotLambdaExecWrapper.INSTRUMENT_HANDLER, }, }); } diff --git a/packages/aws-cdk-lib/aws-lambda/README.md b/packages/aws-cdk-lib/aws-lambda/README.md index bf284c1e495c1..c3eaefbfe74da 100644 --- a/packages/aws-cdk-lib/aws-lambda/README.md +++ b/packages/aws-cdk-lib/aws-lambda/README.md @@ -865,6 +865,8 @@ declare const fn: lambda.Function; const layerArn = lambda.AdotLambdaLayerJavaSdkVersion.V1_19_0.layerArn(fn.stack, fn.architecture); ``` +When using the `AdotLambdaLayerPythonSdkVersion` the `AdotLambdaExecWrapper` needs to be `AdotLambdaExecWrapper.INSTRUMENT_HANDLER` as per [AWS Distro for OpenTelemetry Lambda Support For Python](https://aws-otel.github.io/docs/getting-started/lambda/lambda-python) + ## Lambda with Profiling The following code configures the lambda function with CodeGuru profiling. By default, this creates a new CodeGuru diff --git a/packages/aws-cdk-lib/aws-lambda/lib/adot-layers.ts b/packages/aws-cdk-lib/aws-lambda/lib/adot-layers.ts index 43e9adfd9a89f..0a90489c0caac 100644 --- a/packages/aws-cdk-lib/aws-lambda/lib/adot-layers.ts +++ b/packages/aws-cdk-lib/aws-lambda/lib/adot-layers.ts @@ -184,6 +184,11 @@ export enum AdotLambdaExecWrapper { * propagation for HTTP requests. */ STREAM_HANDLER = '/opt/otel-stream-handler', + + /** + * Wrapping python lambda handlers see https://aws-otel.github.io/docs/getting-started/lambda/lambda-python + */ + INSTRUMENT_HANDLER = '/opt/otel-instrument', } abstract class AdotLambdaLayerVersion { diff --git a/packages/aws-cdk-lib/aws-lambda/lib/function.ts b/packages/aws-cdk-lib/aws-lambda/lib/function.ts index 4e4826eeefd09..daef328fc8f50 100644 --- a/packages/aws-cdk-lib/aws-lambda/lib/function.ts +++ b/packages/aws-cdk-lib/aws-lambda/lib/function.ts @@ -1,5 +1,5 @@ import { Construct, IConstruct } from 'constructs'; -import { AdotInstrumentationConfig } from './adot-layers'; +import { AdotInstrumentationConfig, AdotLambdaExecWrapper } from './adot-layers'; import { AliasOptions, Alias } from './alias'; import { Architecture } from './architecture'; import { Code, CodeConfig } from './code'; @@ -16,7 +16,7 @@ import { CfnFunction } from './lambda.generated'; import { LayerVersion, ILayerVersion } from './layers'; import { LogRetentionRetryOptions } from './log-retention'; import { ParamsAndSecretsLayerVersion } from './params-and-secrets-layers'; -import { Runtime } from './runtime'; +import { Runtime, RuntimeFamily } from './runtime'; import { RuntimeManagementMode } from './runtime-management'; import { addAlias } from './util'; import * as cloudwatch from '../../aws-cloudwatch'; @@ -1157,6 +1157,12 @@ Environment variables can be marked for removal when used in Lambda@Edge by sett throw new Error('Runtime go1.x is not supported by the ADOT Lambda Go SDK'); } + // The Runtime is Python and Adot is set it requires a different EXEC_WRAPPER than the other code bases. + if (this.runtime.family === RuntimeFamily.PYTHON && + props.adotInstrumentation.execWrapper.valueOf() !== AdotLambdaExecWrapper.INSTRUMENT_HANDLER) { + throw new Error('Python Adot Lambda layer requires AdotLambdaExecWrapper.INSTRUMENT_HANDLER'); + } + this.addLayers(LayerVersion.fromLayerVersionArn(this, 'AdotLayer', props.adotInstrumentation.layerVersion._bind(this).arn)); this.addEnvironment('AWS_LAMBDA_EXEC_WRAPPER', props.adotInstrumentation.execWrapper); } diff --git a/packages/aws-cdk-lib/aws-lambda/test/function.test.ts b/packages/aws-cdk-lib/aws-lambda/test/function.test.ts index bf637ac9c00ac..83d25a6c13155 100644 --- a/packages/aws-cdk-lib/aws-lambda/test/function.test.ts +++ b/packages/aws-cdk-lib/aws-lambda/test/function.test.ts @@ -3077,6 +3077,49 @@ describe('function', () => { }); }); + test('adds ADOT instrumentation to a ZIP Lambda function for instrumentation', () => { + // GIVEN + const app = new cdk.App(); + const stack = new cdk.Stack(app, 'Base', { + env: { account: '111111111111', region: 'us-west-2' }, + }); + + // WHEN + new lambda.Function(stack, 'MyLambda', { + code: new lambda.InlineCode('foo'), + handler: 'index.handler', + runtime: lambda.Runtime.PYTHON_3_9, + adotInstrumentation: { + layerVersion: lambda.AdotLayerVersion.fromPythonSdkLayerVersion(lambda.AdotLambdaLayerPythonSdkVersion.V1_13_0), + execWrapper: lambda.AdotLambdaExecWrapper.INSTRUMENT_HANDLER, + }, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', { + Layers: ['arn:aws:lambda:us-west-2:901920570463:layer:aws-otel-python-amd64-ver-1-13-0:1'], + Environment: { + Variables: { + AWS_LAMBDA_EXEC_WRAPPER: '/opt/otel-instrument', + }, + }, + }); + }); + + test('Adot Instrumentation errors out when not using INSTRUMENT_HANDLER', () => { + const stack = new cdk.Stack(); + + expect(() => new lambda.Function(stack, 'Fn1', { + code: new lambda.InlineCode('foo'), + handler: 'index.handler', + runtime: lambda.Runtime.PYTHON_3_10, + adotInstrumentation: { + layerVersion: lambda.AdotLayerVersion.fromPythonSdkLayerVersion(lambda.AdotLambdaLayerPythonSdkVersion.V1_13_0), + execWrapper: lambda.AdotLambdaExecWrapper.REGULAR_HANDLER, + }, + })).toThrow(/Python Adot Lambda layer requires AdotLambdaExecWrapper.INSTRUMENT_HANDLER/); + }); + test('adds ADOT instrumentation to a container image Lambda function', () => { // GIVEN const app = new cdk.App();