diff --git a/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/EnableAdditionalMetadataDefaultTestDeployAssert3F14AD57.assets.json b/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/EnableAdditionalMetadataDefaultTestDeployAssert3F14AD57.assets.json deleted file mode 100644 index 9e44dfaca42dd..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/EnableAdditionalMetadataDefaultTestDeployAssert3F14AD57.assets.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": "39.0.0", - "files": { - "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { - "source": { - "path": "EnableAdditionalMetadataDefaultTestDeployAssert3F14AD57.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/core/test/integ.enable-additional-metadata.js.snapshot/EnableAdditionalMetadataDefaultTestDeployAssert3F14AD57.template.json b/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/EnableAdditionalMetadataDefaultTestDeployAssert3F14AD57.template.json deleted file mode 100644 index ad9d0fb73d1dd..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/EnableAdditionalMetadataDefaultTestDeployAssert3F14AD57.template.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "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/core/test/integ.enable-additional-metadata.js.snapshot/EnableTelemtryStack.assets.json b/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/EnableTelemtryStack.assets.json deleted file mode 100644 index 728de54bd3051..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/EnableTelemtryStack.assets.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": "39.0.0", - "files": { - "b6503dca5951e510ce013d2525009c961587cc7267ceff8ecacb15d7fb7db461": { - "source": { - "path": "EnableTelemtryStack.template.json", - "packaging": "file" - }, - "destinations": { - "current_account-current_region": { - "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "b6503dca5951e510ce013d2525009c961587cc7267ceff8ecacb15d7fb7db461.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/core/test/integ.enable-additional-metadata.js.snapshot/EnableTelemtryStack.template.json b/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/EnableTelemtryStack.template.json deleted file mode 100644 index 40382f0cbd21a..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/EnableTelemtryStack.template.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "Resources": { - "01234test13C610BE": { - "Type": "AWS::SQS::Queue", - "Properties": { - "VisibilityTimeout": 300 - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "MyFunctionServiceRole3C357FF2": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - ] - } - ] - } - }, - "MyFunction3BAA72D1": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "ZipFile": "def handler(event, context):\n\tprint('The function has been invoked.')" - }, - "Handler": "index.handler", - "Role": { - "Fn::GetAtt": [ - "MyFunctionServiceRole3C357FF2", - "Arn" - ] - }, - "Runtime": "python3.8" - }, - "DependsOn": [ - "MyFunctionServiceRole3C357FF2" - ] - } - }, - "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/core/test/integ.enable-additional-metadata.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/cdk.out deleted file mode 100644 index 91e1a8b9901d5..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/cdk.out +++ /dev/null @@ -1 +0,0 @@ -{"version":"39.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/integ.json deleted file mode 100644 index 6d5977883c3cb..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/integ.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": "39.0.0", - "testCases": { - "Enable Additional Metadata/DefaultTest": { - "stacks": [ - "EnableTelemtryStack" - ], - "assertionStack": "Enable Additional Metadata/DefaultTest/DeployAssert", - "assertionStackName": "EnableAdditionalMetadataDefaultTestDeployAssert3F14AD57" - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/manifest.json deleted file mode 100644 index 1ff542acc1419..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/manifest.json +++ /dev/null @@ -1,184 +0,0 @@ -{ - "version": "39.0.0", - "artifacts": { - "EnableTelemtryStack.assets": { - "type": "cdk:asset-manifest", - "properties": { - "file": "EnableTelemtryStack.assets.json", - "requiresBootstrapStackVersion": 6, - "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" - } - }, - "EnableTelemtryStack": { - "type": "aws:cloudformation:stack", - "environment": "aws://unknown-account/unknown-region", - "properties": { - "templateFile": "EnableTelemtryStack.template.json", - "terminationProtection": false, - "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}/b6503dca5951e510ce013d2525009c961587cc7267ceff8ecacb15d7fb7db461.json", - "requiresBootstrapStackVersion": 6, - "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", - "additionalDependencies": [ - "EnableTelemtryStack.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": [ - "EnableTelemtryStack.assets" - ], - "metadata": { - "/EnableTelemtryStack/01234test": [ - { - "type": "aws:cdk:analytics:construct", - "data": { - "visibilityTimeout": { - "amount": 300, - "unit": { - "label": "seconds", - "isoLabel": "S", - "inMillis": 1000 - } - } - } - } - ], - "/EnableTelemtryStack/01234test/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "01234test13C610BE" - } - ], - "/EnableTelemtryStack/MyFunction": [ - { - "type": "aws:cdk:analytics:construct", - "data": { - "runtime": { - "name": "python3.8", - "supportsInlineCode": true, - "family": 2, - "isVariable": false, - "bundlingDockerImage": { - "image": "public.ecr.aws/sam/build-python3.8" - }, - "bundlingImage": { - "image": "public.ecr.aws/sam/build-python3.8" - }, - "supportsCodeGuruProfiling": true, - "supportsSnapStart": false - }, - "handler": "index.handler", - "code": { - "code": "def handler(event, context):\n\tprint('The function has been invoked.')", - "isInline": true - } - } - } - ], - "/EnableTelemtryStack/MyFunction/ServiceRole/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunctionServiceRole3C357FF2" - } - ], - "/EnableTelemtryStack/MyFunction/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunction3BAA72D1" - } - ], - "/EnableTelemtryStack/BootstrapVersion": [ - { - "type": "aws:cdk:logicalId", - "data": "BootstrapVersion" - } - ], - "/EnableTelemtryStack/CheckBootstrapVersion": [ - { - "type": "aws:cdk:logicalId", - "data": "CheckBootstrapVersion" - } - ], - "MyBucketF68F3FF0": [ - { - "type": "aws:cdk:logicalId", - "data": "MyBucketF68F3FF0", - "trace": [ - "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" - ] - } - ], - "CDKMetadata": [ - { - "type": "aws:cdk:logicalId", - "data": "CDKMetadata", - "trace": [ - "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" - ] - } - ] - }, - "displayName": "EnableTelemtryStack" - }, - "EnableAdditionalMetadataDefaultTestDeployAssert3F14AD57.assets": { - "type": "cdk:asset-manifest", - "properties": { - "file": "EnableAdditionalMetadataDefaultTestDeployAssert3F14AD57.assets.json", - "requiresBootstrapStackVersion": 6, - "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" - } - }, - "EnableAdditionalMetadataDefaultTestDeployAssert3F14AD57": { - "type": "aws:cloudformation:stack", - "environment": "aws://unknown-account/unknown-region", - "properties": { - "templateFile": "EnableAdditionalMetadataDefaultTestDeployAssert3F14AD57.template.json", - "terminationProtection": false, - "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": [ - "EnableAdditionalMetadataDefaultTestDeployAssert3F14AD57.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": [ - "EnableAdditionalMetadataDefaultTestDeployAssert3F14AD57.assets" - ], - "metadata": { - "/Enable Additional Metadata/DefaultTest/DeployAssert/BootstrapVersion": [ - { - "type": "aws:cdk:logicalId", - "data": "BootstrapVersion" - } - ], - "/Enable Additional Metadata/DefaultTest/DeployAssert/CheckBootstrapVersion": [ - { - "type": "aws:cdk:logicalId", - "data": "CheckBootstrapVersion" - } - ] - }, - "displayName": "Enable Additional Metadata/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/core/test/integ.enable-additional-metadata.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/tree.json deleted file mode 100644 index 03bb61260684c..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.js.snapshot/tree.json +++ /dev/null @@ -1,261 +0,0 @@ -{ - "version": "tree-0.1", - "tree": { - "id": "App", - "path": "", - "children": { - "EnableTelemtryStack": { - "id": "EnableTelemtryStack", - "path": "EnableTelemtryStack", - "children": { - "01234test": { - "id": "01234test", - "path": "EnableTelemtryStack/01234test", - "children": { - "Resource": { - "id": "Resource", - "path": "EnableTelemtryStack/01234test/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::SQS::Queue", - "aws:cdk:cloudformation:props": { - "visibilityTimeout": 300 - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_sqs.CfnQueue", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_sqs.Queue", - "version": "0.0.0", - "metadata": [ - { - "type": "aws:cdk:analytics:construct", - "data": { - "visibilityTimeout": { - "amount": "*", - "unit": { - "label": "*", - "isoLabel": "*", - "inMillis": "*" - } - } - } - } - ] - } - }, - "MyFunction": { - "id": "MyFunction", - "path": "EnableTelemtryStack/MyFunction", - "children": { - "ServiceRole": { - "id": "ServiceRole", - "path": "EnableTelemtryStack/MyFunction/ServiceRole", - "children": { - "ImportServiceRole": { - "id": "ImportServiceRole", - "path": "EnableTelemtryStack/MyFunction/ServiceRole/ImportServiceRole", - "constructInfo": { - "fqn": "aws-cdk-lib.Resource", - "version": "0.0.0", - "metadata": [] - } - }, - "Resource": { - "id": "Resource", - "path": "EnableTelemtryStack/MyFunction/ServiceRole/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::IAM::Role", - "aws:cdk:cloudformation:props": { - "assumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "managedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - ] - } - ] - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.CfnRole", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.Role", - "version": "0.0.0", - "metadata": [] - } - }, - "Resource": { - "id": "Resource", - "path": "EnableTelemtryStack/MyFunction/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::Lambda::Function", - "aws:cdk:cloudformation:props": { - "code": { - "zipFile": "def handler(event, context):\n\tprint('The function has been invoked.')" - }, - "handler": "index.handler", - "role": { - "Fn::GetAtt": [ - "MyFunctionServiceRole3C357FF2", - "Arn" - ] - }, - "runtime": "python3.8" - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_lambda.Function", - "version": "0.0.0", - "metadata": [ - { - "type": "aws:cdk:analytics:construct", - "data": { - "runtime": { - "name": "*", - "supportsInlineCode": true, - "family": "*", - "isVariable": false, - "bundlingDockerImage": { - "image": "*", - "_imageHash": "*" - }, - "bundlingImage": { - "image": "*", - "_imageHash": "*" - }, - "supportsCodeGuruProfiling": true, - "supportsSnapStart": false - }, - "handler": "*", - "code": { - "code": "*", - "isInline": true - } - } - } - ] - } - }, - "BootstrapVersion": { - "id": "BootstrapVersion", - "path": "EnableTelemtryStack/BootstrapVersion", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnParameter", - "version": "0.0.0" - } - }, - "CheckBootstrapVersion": { - "id": "CheckBootstrapVersion", - "path": "EnableTelemtryStack/CheckBootstrapVersion", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnRule", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.Stack", - "version": "0.0.0" - } - }, - "Enable Additional Metadata": { - "id": "Enable Additional Metadata", - "path": "Enable Additional Metadata", - "children": { - "DefaultTest": { - "id": "DefaultTest", - "path": "Enable Additional Metadata/DefaultTest", - "children": { - "Default": { - "id": "Default", - "path": "Enable Additional Metadata/DefaultTest/Default", - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.4.2" - } - }, - "DeployAssert": { - "id": "DeployAssert", - "path": "Enable Additional Metadata/DefaultTest/DeployAssert", - "children": { - "BootstrapVersion": { - "id": "BootstrapVersion", - "path": "Enable Additional Metadata/DefaultTest/DeployAssert/BootstrapVersion", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnParameter", - "version": "0.0.0" - } - }, - "CheckBootstrapVersion": { - "id": "CheckBootstrapVersion", - "path": "Enable Additional Metadata/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.4.2" - } - } - }, - "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/core/test/integ.enable-additional-metadata.ts b/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.ts deleted file mode 100644 index 6199f6e3c0dcc..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/core/test/integ.enable-additional-metadata.ts +++ /dev/null @@ -1,36 +0,0 @@ -import * as cdk from 'aws-cdk-lib/core'; -import * as integ from '@aws-cdk/integ-tests-alpha'; -import * as lambda from 'aws-cdk-lib/aws-lambda'; -import * as sqs from 'aws-cdk-lib/aws-sqs'; -import { ENABLE_ADDITIONAL_METADATA_COLLECTION } from 'aws-cdk-lib/cx-api'; -import { MetadataType } from 'aws-cdk-lib/core/lib/metadata-resource'; - -/** - * This test creates resources using alphanumeric logical IDs. - */ - -const app = new cdk.App({ - postCliContext: { - [ENABLE_ADDITIONAL_METADATA_COLLECTION]: true, - }, -}); - -const stack = new cdk.Stack(app, 'EnableTelemtryStack'); - -const queueProp = { - visibilityTimeout: cdk.Duration.seconds(300), -}; -const queue = new sqs.Queue(stack, '01234test', queueProp); -queue.node.addMetadata(MetadataType.CONSTRUCT, queueProp); - -const funcProp = { - runtime: lambda.Runtime.PYTHON_3_8, - handler: 'index.handler', - code: lambda.Code.fromInline('def handler(event, context):\n\tprint(\'The function has been invoked.\')'), -}; -const func = new lambda.Function(stack, 'MyFunction', funcProp); -func.node.addMetadata(MetadataType.CONSTRUCT, funcProp); - -new integ.IntegTest(app, 'Enable Additional Metadata', { - testCases: [stack], -}); diff --git a/packages/aws-cdk-lib/core/test/metadata-resource.test.ts b/packages/aws-cdk-lib/core/test/metadata-resource.test.ts index 4e137e93058e9..265a6cf22ff76 100644 --- a/packages/aws-cdk-lib/core/test/metadata-resource.test.ts +++ b/packages/aws-cdk-lib/core/test/metadata-resource.test.ts @@ -1,8 +1,9 @@ import * as zlib from 'zlib'; import { Construct } from 'constructs'; import { Code, Function, Runtime } from '../../aws-lambda'; +import { Queue } from '../../aws-sqs'; import { ENABLE_ADDITIONAL_METADATA_COLLECTION } from '../../cx-api'; -import { App, Stack, IPolicyValidationPluginBeta1, IPolicyValidationContextBeta1, Stage, PolicyValidationPluginReportBeta1, FeatureFlags } from '../lib'; +import { App, Stack, IPolicyValidationPluginBeta1, IPolicyValidationContextBeta1, Stage, PolicyValidationPluginReportBeta1, FeatureFlags, Duration } from '../lib'; import { MetadataType } from '../lib/metadata-resource'; import { formatAnalytics } from '../lib/private/metadata-resource'; import { ConstructInfo } from '../lib/private/runtime-info'; @@ -92,6 +93,34 @@ describe('MetadataResource', () => { expect(stackTemplate1.Resources?.CDKMetadata).toEqual(stackTemplate3.Resources?.CDKMetadata); }); + test('enable additional metadata with metadata', () => { + const myApp = new App({ + analyticsReporting: true, + postCliContext: { + [ENABLE_ADDITIONAL_METADATA_COLLECTION]: true, + }, + }); + + const myStack = new Stack(myApp, 'EnableTelemtryStack'); + const queueProp = { + visibilityTimeout: Duration.seconds(300), + }; + const queue = new Queue(myStack, '01234test', queueProp); + queue.node.addMetadata(MetadataType.CONSTRUCT, queueProp); + + const funcProp = { + runtime: Runtime.PYTHON_3_9, + handler: 'index.handler', + code: Code.fromInline('def handler(event, context):\n\tprint(\'The function has been invoked.\')'), + }; + const func = new Function(myStack, 'MyFunction', funcProp); + func.node.addMetadata(MetadataType.CONSTRUCT, funcProp); + + const template = myApp.synth().getStackByName('EnableTelemtryStack').template; + expect(template.Resources?.CDKMetadata).toBeDefined(); + expect(template.Resources?.CDKMetadata?.Properties?.Analytics).toEqual('v2:deflate64:H4sIAAAAAAAA/8vLT0nVyyrWLzO00DMy0DNQzCrOzNQtKs0rycxN1QuC0ADZIqxKJQAAAA=='); + }); + test('includes the formatted Analytics property', () => { // A very simple check that the jsii runtime psuedo-construct is present. // This check works whether we're running locally or on CodeBuild, on v1 or v2.