From 28ab0c3edbe0e5a5e53eada6b10bbcafa4261865 Mon Sep 17 00:00:00 2001 From: watany <76135106+watany-dev@users.noreply.github.com> Date: Wed, 22 Nov 2023 07:51:03 +0000 Subject: [PATCH 01/14] feat(cloudfront): Setting Runtime of CF2 --- .../test/integ.distribution-function.ts | 1 + .../aws-cloudfront/lib/function.ts | 24 ++++++++++++++- .../aws-cloudfront/test/function.test.ts | 30 ++++++++++++++++++- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function.ts index cf56ff5e90be8..f177a67fbe2d2 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function.ts @@ -7,6 +7,7 @@ const stack = new cdk.Stack(app, 'integ-distribution-function', { env: { region: const cfFunction = new cloudfront.Function(stack, 'Function', { code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'), + runtime: cloudfront.FunctionRuntime.JS_2_0, }); new cloudfront.Distribution(stack, 'Dist', { diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts index d4dd19e98a18b..84390636a6528 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts @@ -122,6 +122,12 @@ export interface FunctionProps { * The source code of the function. */ readonly code: FunctionCode; + + /** + * The runtime environment for the function. + * @default FunctionRuntime.JS_1_0 + */ + readonly runtime?: FunctionRuntime; } /** @@ -165,7 +171,7 @@ export class Function extends Resource implements IFunction { functionCode: props.code.render(), functionConfig: { comment: props.comment ?? this.functionName, - runtime: 'cloudfront-js-1.0', + runtime: props.runtime ?? FunctionRuntime.JS_1_0, }, name: this.functionName, }); @@ -212,3 +218,19 @@ export interface FunctionAssociation { /** The type of event which should invoke the function. */ readonly eventType: FunctionEventType; } + +/** + * The function's runtime environment version. + */ +export enum FunctionRuntime { + + /** + * cloudfront-js-1.0 + */ + JS_1_0 = 'cloudfront-js-1.0', + + /** + * cloudfront-js-2.0 + */ + JS_2_0 = 'cloudfront-js-2.0', +} \ No newline at end of file diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/function.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/function.test.ts index 7573e1c7e65af..53fbdab55293b 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/function.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/function.test.ts @@ -1,7 +1,7 @@ import * as path from 'path'; import { Template } from '../../assertions'; import { App, Stack } from '../../core'; -import { Function, FunctionCode } from '../lib'; +import { Function, FunctionCode, FunctionRuntime } from '../lib'; describe('CloudFront Function', () => { @@ -132,4 +132,32 @@ describe('CloudFront Function', () => { }, }); }); + + test('runtime testing', () => { + const app = new App(); + const stack = new Stack(app, 'Stack', { + env: { account: '123456789012', region: 'testregion' }, + }); + new Function(stack, 'CF2', { + code: FunctionCode.fromInline('code'), + runtime: FunctionRuntime.JS_2_0, + }); + + Template.fromStack(stack).templateMatches({ + Resources: { + CF2D7241DD7: { + Type: 'AWS::CloudFront::Function', + Properties: { + Name: 'testregionStackCF2CE3F783F', + AutoPublish: true, + FunctionCode: 'code', + FunctionConfig: { + Comment: 'testregionStackCF2CE3F783F', + Runtime: 'cloudfront-js-2.0', + }, + }, + }, + }, + }); + }); }); From 9f54b1cc2025ac529f97a70ff9ded7e4cff5629f Mon Sep 17 00:00:00 2001 From: watany <76135106+watany-dev@users.noreply.github.com> Date: Wed, 22 Nov 2023 08:00:35 +0000 Subject: [PATCH 02/14] readme --- packages/aws-cdk-lib/aws-cloudfront/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/aws-cdk-lib/aws-cloudfront/README.md b/packages/aws-cdk-lib/aws-cloudfront/README.md index 4766a7801b6b8..2c33d1506ff73 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/README.md +++ b/packages/aws-cdk-lib/aws-cloudfront/README.md @@ -518,6 +518,7 @@ You can also deploy CloudFront functions and add them to a CloudFront distributi // Add a cloudfront Function to a Distribution const cfFunction = new cloudfront.Function(this, 'Function', { code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'), + runtime: FunctionRuntime.JS_2_0, }); declare const s3Bucket: s3.Bucket; From 86739799005abfccc1fc01a79e55c37e7202be66 Mon Sep 17 00:00:00 2001 From: watany <76135106+watany-dev@users.noreply.github.com> Date: Wed, 22 Nov 2023 09:15:59 +0000 Subject: [PATCH 03/14] integ --- .../integ.distribution-function-runtime.ts | 41 +++++++++++++++++++ .../test/integ.distribution-function.ts | 1 - 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts new file mode 100644 index 0000000000000..4359252deb8df --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts @@ -0,0 +1,41 @@ +import * as cdk from 'aws-cdk-lib'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; +import { TestOrigin } from './test-origin'; +import * as cloudfront from 'aws-cdk-lib/aws-cloudfront'; + +const app = new cdk.App(); +const stack = new cdk.Stack(app, 'integ-distribution-function', { env: { region: 'eu-west-1' } }); + +const cfFunctionRequest = new cloudfront.Function(stack, 'FunctionRequest', { + code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'), +}); + +const cfFunctionResponse = new cloudfront.Function(stack, 'FunctionResponse', { + code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.response }'), +}); + +new cloudfront.Distribution(stack, 'Dist', { + defaultBehavior: { + origin: new TestOrigin('www.example.com'), + cachePolicy: cloudfront.CachePolicy.CACHING_DISABLED, + functionAssociations: [{ + function: cfFunctionRequest, + eventType: cloudfront.FunctionEventType.VIEWER_REQUEST, + }, { + function: cfFunctionResponse, + eventType: cloudfront.FunctionEventType.VIEWER_RESPONSE, + }], + }, +}); + +new cdk.CfnOutput(stack, 'RequestFunctionArn', { value: cfFunctionRequest.functionArn }); +new cdk.CfnOutput(stack, 'RequestFunctionStage', { value: cfFunctionRequest.functionStage }); + +new cdk.CfnOutput(stack, 'ResponseFunctionArn', { value: cfFunctionResponse.functionArn }); +new cdk.CfnOutput(stack, 'ResponseFunctionStage', { value: cfFunctionResponse.functionStage }); + +new IntegTest(app, 'CF2Runtime', { + testCases: [stack], +}); + +app.synth(); diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function.ts index f177a67fbe2d2..cf56ff5e90be8 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function.ts @@ -7,7 +7,6 @@ const stack = new cdk.Stack(app, 'integ-distribution-function', { env: { region: const cfFunction = new cloudfront.Function(stack, 'Function', { code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'), - runtime: cloudfront.FunctionRuntime.JS_2_0, }); new cloudfront.Distribution(stack, 'Dist', { From 757a212072c4542400abf979f72c270f98f4789e Mon Sep 17 00:00:00 2001 From: watany <76135106+watany-dev@users.noreply.github.com> Date: Wed, 22 Nov 2023 13:45:53 +0000 Subject: [PATCH 04/14] snapshot --- ...efaultTestDeployAssertB25F4037.assets.json | 19 ++ ...aultTestDeployAssertB25F4037.template.json | 36 +++ .../cdk.out | 1 + .../integ-distribution-function.assets.json | 20 ++ .../integ-distribution-function.template.json | 141 ++++++++++ .../integ.json | 12 + .../manifest.json | 149 ++++++++++ .../tree.json | 265 ++++++++++++++++++ 8 files changed, 643 insertions(+) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/tree.json diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.assets.json new file mode 100644 index 0000000000000..7b81b6fbbc089 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.assets.json @@ -0,0 +1,19 @@ +{ + "version": "35.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "CF2RuntimeDefaultTestDeployAssertB25F4037.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-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.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-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/cdk.out new file mode 100644 index 0000000000000..c5cb2e5de6344 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"35.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.assets.json new file mode 100644 index 0000000000000..a164e0f9439f9 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.assets.json @@ -0,0 +1,20 @@ +{ + "version": "35.0.0", + "files": { + "566341e5b3961d17fc2b60a44eba712f6e295016886f23ce22320d2c3a11f6bc": { + "source": { + "path": "integ-distribution-function.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-eu-west-1": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-eu-west-1", + "objectKey": "566341e5b3961d17fc2b60a44eba712f6e295016886f23ce22320d2c3a11f6bc.json", + "region": "eu-west-1", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-eu-west-1" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.template.json new file mode 100644 index 0000000000000..e8419a9b8ed44 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.template.json @@ -0,0 +1,141 @@ +{ + "Resources": { + "FunctionRequest95528B2F": { + "Type": "AWS::CloudFront::Function", + "Properties": { + "AutoPublish": true, + "FunctionCode": "function handler(event) { return event.request }", + "FunctionConfig": { + "Comment": "eu-west-1integdistributionfunctionFunctionRequest8E65DEEB", + "Runtime": "cloudfront-js-1.0" + }, + "Name": "eu-west-1integdistributionfunctionFunctionRequest8E65DEEB" + } + }, + "FunctionResponse4EF2D1D3": { + "Type": "AWS::CloudFront::Function", + "Properties": { + "AutoPublish": true, + "FunctionCode": "function handler(event) { return event.response }", + "FunctionConfig": { + "Comment": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1", + "Runtime": "cloudfront-js-1.0" + }, + "Name": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1" + } + }, + "DistB3B78991": { + "Type": "AWS::CloudFront::Distribution", + "Properties": { + "DistributionConfig": { + "DefaultCacheBehavior": { + "CachePolicyId": "4135ea2d-6df8-44a3-9df3-4b5a84be39ad", + "Compress": true, + "FunctionAssociations": [ + { + "EventType": "viewer-request", + "FunctionARN": { + "Fn::GetAtt": [ + "FunctionRequest95528B2F", + "FunctionARN" + ] + } + }, + { + "EventType": "viewer-response", + "FunctionARN": { + "Fn::GetAtt": [ + "FunctionResponse4EF2D1D3", + "FunctionARN" + ] + } + } + ], + "TargetOriginId": "integdistributionfunctionDistOrigin1D1E9DF17", + "ViewerProtocolPolicy": "allow-all" + }, + "Enabled": true, + "HttpVersion": "http2", + "IPV6Enabled": true, + "Origins": [ + { + "CustomOriginConfig": { + "OriginProtocolPolicy": "https-only" + }, + "DomainName": "www.example.com", + "Id": "integdistributionfunctionDistOrigin1D1E9DF17" + } + ] + } + } + } + }, + "Outputs": { + "RequestFunctionArn": { + "Value": { + "Fn::GetAtt": [ + "FunctionRequest95528B2F", + "FunctionARN" + ] + } + }, + "RequestFunctionStage": { + "Value": { + "Fn::GetAtt": [ + "FunctionRequest95528B2F", + "Stage" + ] + } + }, + "ResponseFunctionArn": { + "Value": { + "Fn::GetAtt": [ + "FunctionResponse4EF2D1D3", + "FunctionARN" + ] + } + }, + "ResponseFunctionStage": { + "Value": { + "Fn::GetAtt": [ + "FunctionResponse4EF2D1D3", + "Stage" + ] + } + } + }, + "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-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ.json new file mode 100644 index 0000000000000..3f83a1ff45115 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "35.0.0", + "testCases": { + "CF2Runtime/DefaultTest": { + "stacks": [ + "integ-distribution-function" + ], + "assertionStack": "CF2Runtime/DefaultTest/DeployAssert", + "assertionStackName": "CF2RuntimeDefaultTestDeployAssertB25F4037" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/manifest.json new file mode 100644 index 0000000000000..cc6443b92a879 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/manifest.json @@ -0,0 +1,149 @@ +{ + "version": "35.0.0", + "artifacts": { + "integ-distribution-function.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "integ-distribution-function.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "integ-distribution-function": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/eu-west-1", + "properties": { + "templateFile": "integ-distribution-function.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-eu-west-1", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-eu-west-1", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-eu-west-1/566341e5b3961d17fc2b60a44eba712f6e295016886f23ce22320d2c3a11f6bc.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "integ-distribution-function.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-eu-west-1", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "integ-distribution-function.assets" + ], + "metadata": { + "/integ-distribution-function/FunctionRequest/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "FunctionRequest95528B2F" + } + ], + "/integ-distribution-function/FunctionResponse/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "FunctionResponse4EF2D1D3" + } + ], + "/integ-distribution-function/Dist/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "DistB3B78991" + } + ], + "/integ-distribution-function/RequestFunctionArn": [ + { + "type": "aws:cdk:logicalId", + "data": "RequestFunctionArn" + } + ], + "/integ-distribution-function/RequestFunctionStage": [ + { + "type": "aws:cdk:logicalId", + "data": "RequestFunctionStage" + } + ], + "/integ-distribution-function/ResponseFunctionArn": [ + { + "type": "aws:cdk:logicalId", + "data": "ResponseFunctionArn" + } + ], + "/integ-distribution-function/ResponseFunctionStage": [ + { + "type": "aws:cdk:logicalId", + "data": "ResponseFunctionStage" + } + ], + "/integ-distribution-function/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/integ-distribution-function/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "integ-distribution-function" + }, + "CF2RuntimeDefaultTestDeployAssertB25F4037.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "CF2RuntimeDefaultTestDeployAssertB25F4037.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "CF2RuntimeDefaultTestDeployAssertB25F4037": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "CF2RuntimeDefaultTestDeployAssertB25F4037.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": [ + "CF2RuntimeDefaultTestDeployAssertB25F4037.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": [ + "CF2RuntimeDefaultTestDeployAssertB25F4037.assets" + ], + "metadata": { + "/CF2Runtime/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/CF2Runtime/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "CF2Runtime/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-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/tree.json new file mode 100644 index 0000000000000..988c2366038c6 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/tree.json @@ -0,0 +1,265 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "integ-distribution-function": { + "id": "integ-distribution-function", + "path": "integ-distribution-function", + "children": { + "FunctionRequest": { + "id": "FunctionRequest", + "path": "integ-distribution-function/FunctionRequest", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-distribution-function/FunctionRequest/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CloudFront::Function", + "aws:cdk:cloudformation:props": { + "autoPublish": true, + "functionCode": "function handler(event) { return event.request }", + "functionConfig": { + "comment": "eu-west-1integdistributionfunctionFunctionRequest8E65DEEB", + "runtime": "cloudfront-js-1.0" + }, + "name": "eu-west-1integdistributionfunctionFunctionRequest8E65DEEB" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudfront.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudfront.Function", + "version": "0.0.0" + } + }, + "FunctionResponse": { + "id": "FunctionResponse", + "path": "integ-distribution-function/FunctionResponse", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-distribution-function/FunctionResponse/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CloudFront::Function", + "aws:cdk:cloudformation:props": { + "autoPublish": true, + "functionCode": "function handler(event) { return event.response }", + "functionConfig": { + "comment": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1", + "runtime": "cloudfront-js-1.0" + }, + "name": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudfront.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudfront.Function", + "version": "0.0.0" + } + }, + "Dist": { + "id": "Dist", + "path": "integ-distribution-function/Dist", + "children": { + "Origin1": { + "id": "Origin1", + "path": "integ-distribution-function/Dist/Origin1", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-distribution-function/Dist/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CloudFront::Distribution", + "aws:cdk:cloudformation:props": { + "distributionConfig": { + "enabled": true, + "origins": [ + { + "domainName": "www.example.com", + "id": "integdistributionfunctionDistOrigin1D1E9DF17", + "customOriginConfig": { + "originProtocolPolicy": "https-only" + } + } + ], + "defaultCacheBehavior": { + "pathPattern": "*", + "targetOriginId": "integdistributionfunctionDistOrigin1D1E9DF17", + "cachePolicyId": "4135ea2d-6df8-44a3-9df3-4b5a84be39ad", + "compress": true, + "viewerProtocolPolicy": "allow-all", + "functionAssociations": [ + { + "functionArn": { + "Fn::GetAtt": [ + "FunctionRequest95528B2F", + "FunctionARN" + ] + }, + "eventType": "viewer-request" + }, + { + "functionArn": { + "Fn::GetAtt": [ + "FunctionResponse4EF2D1D3", + "FunctionARN" + ] + }, + "eventType": "viewer-response" + } + ] + }, + "httpVersion": "http2", + "ipv6Enabled": true + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudfront.CfnDistribution", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudfront.Distribution", + "version": "0.0.0" + } + }, + "RequestFunctionArn": { + "id": "RequestFunctionArn", + "path": "integ-distribution-function/RequestFunctionArn", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "RequestFunctionStage": { + "id": "RequestFunctionStage", + "path": "integ-distribution-function/RequestFunctionStage", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "ResponseFunctionArn": { + "id": "ResponseFunctionArn", + "path": "integ-distribution-function/ResponseFunctionArn", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "ResponseFunctionStage": { + "id": "ResponseFunctionStage", + "path": "integ-distribution-function/ResponseFunctionStage", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "integ-distribution-function/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "integ-distribution-function/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "CF2Runtime": { + "id": "CF2Runtime", + "path": "CF2Runtime", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "CF2Runtime/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "CF2Runtime/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "CF2Runtime/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "CF2Runtime/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "CF2Runtime/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.3.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file From d3fb72320640070584a6db1c8fddbef397db1b68 Mon Sep 17 00:00:00 2001 From: watany <76135106+watany-dev@users.noreply.github.com> Date: Wed, 22 Nov 2023 15:26:57 +0000 Subject: [PATCH 05/14] Revert "snapshot" This reverts commit 757a212072c4542400abf979f72c270f98f4789e. --- ...efaultTestDeployAssertB25F4037.assets.json | 19 -- ...aultTestDeployAssertB25F4037.template.json | 36 --- .../cdk.out | 1 - .../integ-distribution-function.assets.json | 20 -- .../integ-distribution-function.template.json | 141 ---------- .../integ.json | 12 - .../manifest.json | 149 ---------- .../tree.json | 265 ------------------ 8 files changed, 643 deletions(-) delete mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.assets.json delete mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.template.json delete mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/cdk.out delete mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.assets.json delete mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.template.json delete mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ.json delete mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/manifest.json delete mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/tree.json diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.assets.json deleted file mode 100644 index 7b81b6fbbc089..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.assets.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": "35.0.0", - "files": { - "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { - "source": { - "path": "CF2RuntimeDefaultTestDeployAssertB25F4037.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-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.template.json deleted file mode 100644 index ad9d0fb73d1dd..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.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/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/cdk.out deleted file mode 100644 index c5cb2e5de6344..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/cdk.out +++ /dev/null @@ -1 +0,0 @@ -{"version":"35.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.assets.json deleted file mode 100644 index a164e0f9439f9..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.assets.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": "35.0.0", - "files": { - "566341e5b3961d17fc2b60a44eba712f6e295016886f23ce22320d2c3a11f6bc": { - "source": { - "path": "integ-distribution-function.template.json", - "packaging": "file" - }, - "destinations": { - "current_account-eu-west-1": { - "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-eu-west-1", - "objectKey": "566341e5b3961d17fc2b60a44eba712f6e295016886f23ce22320d2c3a11f6bc.json", - "region": "eu-west-1", - "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-eu-west-1" - } - } - } - }, - "dockerImages": {} -} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.template.json deleted file mode 100644 index e8419a9b8ed44..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ-distribution-function.template.json +++ /dev/null @@ -1,141 +0,0 @@ -{ - "Resources": { - "FunctionRequest95528B2F": { - "Type": "AWS::CloudFront::Function", - "Properties": { - "AutoPublish": true, - "FunctionCode": "function handler(event) { return event.request }", - "FunctionConfig": { - "Comment": "eu-west-1integdistributionfunctionFunctionRequest8E65DEEB", - "Runtime": "cloudfront-js-1.0" - }, - "Name": "eu-west-1integdistributionfunctionFunctionRequest8E65DEEB" - } - }, - "FunctionResponse4EF2D1D3": { - "Type": "AWS::CloudFront::Function", - "Properties": { - "AutoPublish": true, - "FunctionCode": "function handler(event) { return event.response }", - "FunctionConfig": { - "Comment": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1", - "Runtime": "cloudfront-js-1.0" - }, - "Name": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1" - } - }, - "DistB3B78991": { - "Type": "AWS::CloudFront::Distribution", - "Properties": { - "DistributionConfig": { - "DefaultCacheBehavior": { - "CachePolicyId": "4135ea2d-6df8-44a3-9df3-4b5a84be39ad", - "Compress": true, - "FunctionAssociations": [ - { - "EventType": "viewer-request", - "FunctionARN": { - "Fn::GetAtt": [ - "FunctionRequest95528B2F", - "FunctionARN" - ] - } - }, - { - "EventType": "viewer-response", - "FunctionARN": { - "Fn::GetAtt": [ - "FunctionResponse4EF2D1D3", - "FunctionARN" - ] - } - } - ], - "TargetOriginId": "integdistributionfunctionDistOrigin1D1E9DF17", - "ViewerProtocolPolicy": "allow-all" - }, - "Enabled": true, - "HttpVersion": "http2", - "IPV6Enabled": true, - "Origins": [ - { - "CustomOriginConfig": { - "OriginProtocolPolicy": "https-only" - }, - "DomainName": "www.example.com", - "Id": "integdistributionfunctionDistOrigin1D1E9DF17" - } - ] - } - } - } - }, - "Outputs": { - "RequestFunctionArn": { - "Value": { - "Fn::GetAtt": [ - "FunctionRequest95528B2F", - "FunctionARN" - ] - } - }, - "RequestFunctionStage": { - "Value": { - "Fn::GetAtt": [ - "FunctionRequest95528B2F", - "Stage" - ] - } - }, - "ResponseFunctionArn": { - "Value": { - "Fn::GetAtt": [ - "FunctionResponse4EF2D1D3", - "FunctionARN" - ] - } - }, - "ResponseFunctionStage": { - "Value": { - "Fn::GetAtt": [ - "FunctionResponse4EF2D1D3", - "Stage" - ] - } - } - }, - "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-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ.json deleted file mode 100644 index 3f83a1ff45115..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/integ.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": "35.0.0", - "testCases": { - "CF2Runtime/DefaultTest": { - "stacks": [ - "integ-distribution-function" - ], - "assertionStack": "CF2Runtime/DefaultTest/DeployAssert", - "assertionStackName": "CF2RuntimeDefaultTestDeployAssertB25F4037" - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/manifest.json deleted file mode 100644 index cc6443b92a879..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/manifest.json +++ /dev/null @@ -1,149 +0,0 @@ -{ - "version": "35.0.0", - "artifacts": { - "integ-distribution-function.assets": { - "type": "cdk:asset-manifest", - "properties": { - "file": "integ-distribution-function.assets.json", - "requiresBootstrapStackVersion": 6, - "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" - } - }, - "integ-distribution-function": { - "type": "aws:cloudformation:stack", - "environment": "aws://unknown-account/eu-west-1", - "properties": { - "templateFile": "integ-distribution-function.template.json", - "terminationProtection": false, - "validateOnSynth": false, - "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-eu-west-1", - "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-eu-west-1", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-eu-west-1/566341e5b3961d17fc2b60a44eba712f6e295016886f23ce22320d2c3a11f6bc.json", - "requiresBootstrapStackVersion": 6, - "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", - "additionalDependencies": [ - "integ-distribution-function.assets" - ], - "lookupRole": { - "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-eu-west-1", - "requiresBootstrapStackVersion": 8, - "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" - } - }, - "dependencies": [ - "integ-distribution-function.assets" - ], - "metadata": { - "/integ-distribution-function/FunctionRequest/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "FunctionRequest95528B2F" - } - ], - "/integ-distribution-function/FunctionResponse/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "FunctionResponse4EF2D1D3" - } - ], - "/integ-distribution-function/Dist/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "DistB3B78991" - } - ], - "/integ-distribution-function/RequestFunctionArn": [ - { - "type": "aws:cdk:logicalId", - "data": "RequestFunctionArn" - } - ], - "/integ-distribution-function/RequestFunctionStage": [ - { - "type": "aws:cdk:logicalId", - "data": "RequestFunctionStage" - } - ], - "/integ-distribution-function/ResponseFunctionArn": [ - { - "type": "aws:cdk:logicalId", - "data": "ResponseFunctionArn" - } - ], - "/integ-distribution-function/ResponseFunctionStage": [ - { - "type": "aws:cdk:logicalId", - "data": "ResponseFunctionStage" - } - ], - "/integ-distribution-function/BootstrapVersion": [ - { - "type": "aws:cdk:logicalId", - "data": "BootstrapVersion" - } - ], - "/integ-distribution-function/CheckBootstrapVersion": [ - { - "type": "aws:cdk:logicalId", - "data": "CheckBootstrapVersion" - } - ] - }, - "displayName": "integ-distribution-function" - }, - "CF2RuntimeDefaultTestDeployAssertB25F4037.assets": { - "type": "cdk:asset-manifest", - "properties": { - "file": "CF2RuntimeDefaultTestDeployAssertB25F4037.assets.json", - "requiresBootstrapStackVersion": 6, - "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" - } - }, - "CF2RuntimeDefaultTestDeployAssertB25F4037": { - "type": "aws:cloudformation:stack", - "environment": "aws://unknown-account/unknown-region", - "properties": { - "templateFile": "CF2RuntimeDefaultTestDeployAssertB25F4037.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": [ - "CF2RuntimeDefaultTestDeployAssertB25F4037.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": [ - "CF2RuntimeDefaultTestDeployAssertB25F4037.assets" - ], - "metadata": { - "/CF2Runtime/DefaultTest/DeployAssert/BootstrapVersion": [ - { - "type": "aws:cdk:logicalId", - "data": "BootstrapVersion" - } - ], - "/CF2Runtime/DefaultTest/DeployAssert/CheckBootstrapVersion": [ - { - "type": "aws:cdk:logicalId", - "data": "CheckBootstrapVersion" - } - ] - }, - "displayName": "CF2Runtime/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-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/tree.json deleted file mode 100644 index 988c2366038c6..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts.snapshot/tree.json +++ /dev/null @@ -1,265 +0,0 @@ -{ - "version": "tree-0.1", - "tree": { - "id": "App", - "path": "", - "children": { - "integ-distribution-function": { - "id": "integ-distribution-function", - "path": "integ-distribution-function", - "children": { - "FunctionRequest": { - "id": "FunctionRequest", - "path": "integ-distribution-function/FunctionRequest", - "children": { - "Resource": { - "id": "Resource", - "path": "integ-distribution-function/FunctionRequest/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::CloudFront::Function", - "aws:cdk:cloudformation:props": { - "autoPublish": true, - "functionCode": "function handler(event) { return event.request }", - "functionConfig": { - "comment": "eu-west-1integdistributionfunctionFunctionRequest8E65DEEB", - "runtime": "cloudfront-js-1.0" - }, - "name": "eu-west-1integdistributionfunctionFunctionRequest8E65DEEB" - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_cloudfront.CfnFunction", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_cloudfront.Function", - "version": "0.0.0" - } - }, - "FunctionResponse": { - "id": "FunctionResponse", - "path": "integ-distribution-function/FunctionResponse", - "children": { - "Resource": { - "id": "Resource", - "path": "integ-distribution-function/FunctionResponse/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::CloudFront::Function", - "aws:cdk:cloudformation:props": { - "autoPublish": true, - "functionCode": "function handler(event) { return event.response }", - "functionConfig": { - "comment": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1", - "runtime": "cloudfront-js-1.0" - }, - "name": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1" - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_cloudfront.CfnFunction", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_cloudfront.Function", - "version": "0.0.0" - } - }, - "Dist": { - "id": "Dist", - "path": "integ-distribution-function/Dist", - "children": { - "Origin1": { - "id": "Origin1", - "path": "integ-distribution-function/Dist/Origin1", - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" - } - }, - "Resource": { - "id": "Resource", - "path": "integ-distribution-function/Dist/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::CloudFront::Distribution", - "aws:cdk:cloudformation:props": { - "distributionConfig": { - "enabled": true, - "origins": [ - { - "domainName": "www.example.com", - "id": "integdistributionfunctionDistOrigin1D1E9DF17", - "customOriginConfig": { - "originProtocolPolicy": "https-only" - } - } - ], - "defaultCacheBehavior": { - "pathPattern": "*", - "targetOriginId": "integdistributionfunctionDistOrigin1D1E9DF17", - "cachePolicyId": "4135ea2d-6df8-44a3-9df3-4b5a84be39ad", - "compress": true, - "viewerProtocolPolicy": "allow-all", - "functionAssociations": [ - { - "functionArn": { - "Fn::GetAtt": [ - "FunctionRequest95528B2F", - "FunctionARN" - ] - }, - "eventType": "viewer-request" - }, - { - "functionArn": { - "Fn::GetAtt": [ - "FunctionResponse4EF2D1D3", - "FunctionARN" - ] - }, - "eventType": "viewer-response" - } - ] - }, - "httpVersion": "http2", - "ipv6Enabled": true - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_cloudfront.CfnDistribution", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_cloudfront.Distribution", - "version": "0.0.0" - } - }, - "RequestFunctionArn": { - "id": "RequestFunctionArn", - "path": "integ-distribution-function/RequestFunctionArn", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnOutput", - "version": "0.0.0" - } - }, - "RequestFunctionStage": { - "id": "RequestFunctionStage", - "path": "integ-distribution-function/RequestFunctionStage", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnOutput", - "version": "0.0.0" - } - }, - "ResponseFunctionArn": { - "id": "ResponseFunctionArn", - "path": "integ-distribution-function/ResponseFunctionArn", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnOutput", - "version": "0.0.0" - } - }, - "ResponseFunctionStage": { - "id": "ResponseFunctionStage", - "path": "integ-distribution-function/ResponseFunctionStage", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnOutput", - "version": "0.0.0" - } - }, - "BootstrapVersion": { - "id": "BootstrapVersion", - "path": "integ-distribution-function/BootstrapVersion", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnParameter", - "version": "0.0.0" - } - }, - "CheckBootstrapVersion": { - "id": "CheckBootstrapVersion", - "path": "integ-distribution-function/CheckBootstrapVersion", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnRule", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.Stack", - "version": "0.0.0" - } - }, - "CF2Runtime": { - "id": "CF2Runtime", - "path": "CF2Runtime", - "children": { - "DefaultTest": { - "id": "DefaultTest", - "path": "CF2Runtime/DefaultTest", - "children": { - "Default": { - "id": "Default", - "path": "CF2Runtime/DefaultTest/Default", - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" - } - }, - "DeployAssert": { - "id": "DeployAssert", - "path": "CF2Runtime/DefaultTest/DeployAssert", - "children": { - "BootstrapVersion": { - "id": "BootstrapVersion", - "path": "CF2Runtime/DefaultTest/DeployAssert/BootstrapVersion", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnParameter", - "version": "0.0.0" - } - }, - "CheckBootstrapVersion": { - "id": "CheckBootstrapVersion", - "path": "CF2Runtime/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.3.0" - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.App", - "version": "0.0.0" - } - } -} \ No newline at end of file From 0b165cdeca099477f1db52e25bf44ecb6b959401 Mon Sep 17 00:00:00 2001 From: watany <76135106+watany-dev@users.noreply.github.com> Date: Wed, 22 Nov 2023 15:40:54 +0000 Subject: [PATCH 06/14] integ --- ...efaultTestDeployAssertB25F4037.assets.json | 19 ++ ...aultTestDeployAssertB25F4037.template.json | 36 +++ .../cdk.out | 1 + .../integ-distribution-function.assets.json | 20 ++ .../integ-distribution-function.template.json | 141 ++++++++++ .../integ.json | 12 + .../manifest.json | 149 ++++++++++ .../tree.json | 265 ++++++++++++++++++ 8 files changed, 643 insertions(+) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/tree.json diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.assets.json new file mode 100644 index 0000000000000..7b81b6fbbc089 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.assets.json @@ -0,0 +1,19 @@ +{ + "version": "35.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "CF2RuntimeDefaultTestDeployAssertB25F4037.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-cloudfront/test/integ.distribution-function-runtime.js.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/CF2RuntimeDefaultTestDeployAssertB25F4037.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-cloudfront/test/integ.distribution-function-runtime.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/cdk.out new file mode 100644 index 0000000000000..c5cb2e5de6344 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"35.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.assets.json new file mode 100644 index 0000000000000..a164e0f9439f9 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.assets.json @@ -0,0 +1,20 @@ +{ + "version": "35.0.0", + "files": { + "566341e5b3961d17fc2b60a44eba712f6e295016886f23ce22320d2c3a11f6bc": { + "source": { + "path": "integ-distribution-function.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-eu-west-1": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-eu-west-1", + "objectKey": "566341e5b3961d17fc2b60a44eba712f6e295016886f23ce22320d2c3a11f6bc.json", + "region": "eu-west-1", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-eu-west-1" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.template.json new file mode 100644 index 0000000000000..e8419a9b8ed44 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.template.json @@ -0,0 +1,141 @@ +{ + "Resources": { + "FunctionRequest95528B2F": { + "Type": "AWS::CloudFront::Function", + "Properties": { + "AutoPublish": true, + "FunctionCode": "function handler(event) { return event.request }", + "FunctionConfig": { + "Comment": "eu-west-1integdistributionfunctionFunctionRequest8E65DEEB", + "Runtime": "cloudfront-js-1.0" + }, + "Name": "eu-west-1integdistributionfunctionFunctionRequest8E65DEEB" + } + }, + "FunctionResponse4EF2D1D3": { + "Type": "AWS::CloudFront::Function", + "Properties": { + "AutoPublish": true, + "FunctionCode": "function handler(event) { return event.response }", + "FunctionConfig": { + "Comment": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1", + "Runtime": "cloudfront-js-1.0" + }, + "Name": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1" + } + }, + "DistB3B78991": { + "Type": "AWS::CloudFront::Distribution", + "Properties": { + "DistributionConfig": { + "DefaultCacheBehavior": { + "CachePolicyId": "4135ea2d-6df8-44a3-9df3-4b5a84be39ad", + "Compress": true, + "FunctionAssociations": [ + { + "EventType": "viewer-request", + "FunctionARN": { + "Fn::GetAtt": [ + "FunctionRequest95528B2F", + "FunctionARN" + ] + } + }, + { + "EventType": "viewer-response", + "FunctionARN": { + "Fn::GetAtt": [ + "FunctionResponse4EF2D1D3", + "FunctionARN" + ] + } + } + ], + "TargetOriginId": "integdistributionfunctionDistOrigin1D1E9DF17", + "ViewerProtocolPolicy": "allow-all" + }, + "Enabled": true, + "HttpVersion": "http2", + "IPV6Enabled": true, + "Origins": [ + { + "CustomOriginConfig": { + "OriginProtocolPolicy": "https-only" + }, + "DomainName": "www.example.com", + "Id": "integdistributionfunctionDistOrigin1D1E9DF17" + } + ] + } + } + } + }, + "Outputs": { + "RequestFunctionArn": { + "Value": { + "Fn::GetAtt": [ + "FunctionRequest95528B2F", + "FunctionARN" + ] + } + }, + "RequestFunctionStage": { + "Value": { + "Fn::GetAtt": [ + "FunctionRequest95528B2F", + "Stage" + ] + } + }, + "ResponseFunctionArn": { + "Value": { + "Fn::GetAtt": [ + "FunctionResponse4EF2D1D3", + "FunctionARN" + ] + } + }, + "ResponseFunctionStage": { + "Value": { + "Fn::GetAtt": [ + "FunctionResponse4EF2D1D3", + "Stage" + ] + } + } + }, + "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-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ.json new file mode 100644 index 0000000000000..3f83a1ff45115 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "35.0.0", + "testCases": { + "CF2Runtime/DefaultTest": { + "stacks": [ + "integ-distribution-function" + ], + "assertionStack": "CF2Runtime/DefaultTest/DeployAssert", + "assertionStackName": "CF2RuntimeDefaultTestDeployAssertB25F4037" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/manifest.json new file mode 100644 index 0000000000000..cc6443b92a879 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/manifest.json @@ -0,0 +1,149 @@ +{ + "version": "35.0.0", + "artifacts": { + "integ-distribution-function.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "integ-distribution-function.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "integ-distribution-function": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/eu-west-1", + "properties": { + "templateFile": "integ-distribution-function.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-eu-west-1", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-eu-west-1", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-eu-west-1/566341e5b3961d17fc2b60a44eba712f6e295016886f23ce22320d2c3a11f6bc.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "integ-distribution-function.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-eu-west-1", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "integ-distribution-function.assets" + ], + "metadata": { + "/integ-distribution-function/FunctionRequest/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "FunctionRequest95528B2F" + } + ], + "/integ-distribution-function/FunctionResponse/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "FunctionResponse4EF2D1D3" + } + ], + "/integ-distribution-function/Dist/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "DistB3B78991" + } + ], + "/integ-distribution-function/RequestFunctionArn": [ + { + "type": "aws:cdk:logicalId", + "data": "RequestFunctionArn" + } + ], + "/integ-distribution-function/RequestFunctionStage": [ + { + "type": "aws:cdk:logicalId", + "data": "RequestFunctionStage" + } + ], + "/integ-distribution-function/ResponseFunctionArn": [ + { + "type": "aws:cdk:logicalId", + "data": "ResponseFunctionArn" + } + ], + "/integ-distribution-function/ResponseFunctionStage": [ + { + "type": "aws:cdk:logicalId", + "data": "ResponseFunctionStage" + } + ], + "/integ-distribution-function/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/integ-distribution-function/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "integ-distribution-function" + }, + "CF2RuntimeDefaultTestDeployAssertB25F4037.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "CF2RuntimeDefaultTestDeployAssertB25F4037.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "CF2RuntimeDefaultTestDeployAssertB25F4037": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "CF2RuntimeDefaultTestDeployAssertB25F4037.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": [ + "CF2RuntimeDefaultTestDeployAssertB25F4037.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": [ + "CF2RuntimeDefaultTestDeployAssertB25F4037.assets" + ], + "metadata": { + "/CF2Runtime/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/CF2Runtime/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "CF2Runtime/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-cloudfront/test/integ.distribution-function-runtime.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/tree.json new file mode 100644 index 0000000000000..988c2366038c6 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/tree.json @@ -0,0 +1,265 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "integ-distribution-function": { + "id": "integ-distribution-function", + "path": "integ-distribution-function", + "children": { + "FunctionRequest": { + "id": "FunctionRequest", + "path": "integ-distribution-function/FunctionRequest", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-distribution-function/FunctionRequest/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CloudFront::Function", + "aws:cdk:cloudformation:props": { + "autoPublish": true, + "functionCode": "function handler(event) { return event.request }", + "functionConfig": { + "comment": "eu-west-1integdistributionfunctionFunctionRequest8E65DEEB", + "runtime": "cloudfront-js-1.0" + }, + "name": "eu-west-1integdistributionfunctionFunctionRequest8E65DEEB" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudfront.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudfront.Function", + "version": "0.0.0" + } + }, + "FunctionResponse": { + "id": "FunctionResponse", + "path": "integ-distribution-function/FunctionResponse", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-distribution-function/FunctionResponse/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CloudFront::Function", + "aws:cdk:cloudformation:props": { + "autoPublish": true, + "functionCode": "function handler(event) { return event.response }", + "functionConfig": { + "comment": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1", + "runtime": "cloudfront-js-1.0" + }, + "name": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudfront.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudfront.Function", + "version": "0.0.0" + } + }, + "Dist": { + "id": "Dist", + "path": "integ-distribution-function/Dist", + "children": { + "Origin1": { + "id": "Origin1", + "path": "integ-distribution-function/Dist/Origin1", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-distribution-function/Dist/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CloudFront::Distribution", + "aws:cdk:cloudformation:props": { + "distributionConfig": { + "enabled": true, + "origins": [ + { + "domainName": "www.example.com", + "id": "integdistributionfunctionDistOrigin1D1E9DF17", + "customOriginConfig": { + "originProtocolPolicy": "https-only" + } + } + ], + "defaultCacheBehavior": { + "pathPattern": "*", + "targetOriginId": "integdistributionfunctionDistOrigin1D1E9DF17", + "cachePolicyId": "4135ea2d-6df8-44a3-9df3-4b5a84be39ad", + "compress": true, + "viewerProtocolPolicy": "allow-all", + "functionAssociations": [ + { + "functionArn": { + "Fn::GetAtt": [ + "FunctionRequest95528B2F", + "FunctionARN" + ] + }, + "eventType": "viewer-request" + }, + { + "functionArn": { + "Fn::GetAtt": [ + "FunctionResponse4EF2D1D3", + "FunctionARN" + ] + }, + "eventType": "viewer-response" + } + ] + }, + "httpVersion": "http2", + "ipv6Enabled": true + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudfront.CfnDistribution", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudfront.Distribution", + "version": "0.0.0" + } + }, + "RequestFunctionArn": { + "id": "RequestFunctionArn", + "path": "integ-distribution-function/RequestFunctionArn", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "RequestFunctionStage": { + "id": "RequestFunctionStage", + "path": "integ-distribution-function/RequestFunctionStage", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "ResponseFunctionArn": { + "id": "ResponseFunctionArn", + "path": "integ-distribution-function/ResponseFunctionArn", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "ResponseFunctionStage": { + "id": "ResponseFunctionStage", + "path": "integ-distribution-function/ResponseFunctionStage", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "integ-distribution-function/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "integ-distribution-function/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "CF2Runtime": { + "id": "CF2Runtime", + "path": "CF2Runtime", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "CF2Runtime/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "CF2Runtime/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "CF2Runtime/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "CF2Runtime/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "CF2Runtime/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.3.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file From c2096329d57b536f5728a69888ecd2024886674b Mon Sep 17 00:00:00 2001 From: watany <76135106+watany-dev@users.noreply.github.com> Date: Wed, 22 Nov 2023 16:17:14 +0000 Subject: [PATCH 07/14] fix readme --- packages/aws-cdk-lib/aws-cloudfront/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/README.md b/packages/aws-cdk-lib/aws-cloudfront/README.md index 2c33d1506ff73..ec156dbb2293f 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/README.md +++ b/packages/aws-cdk-lib/aws-cloudfront/README.md @@ -518,7 +518,7 @@ You can also deploy CloudFront functions and add them to a CloudFront distributi // Add a cloudfront Function to a Distribution const cfFunction = new cloudfront.Function(this, 'Function', { code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'), - runtime: FunctionRuntime.JS_2_0, + runtime: cloudfront.FunctionRuntime.JS_2_0, }); declare const s3Bucket: s3.Bucket; From a4d220c46e70e3ea25ffd1a2d254af259e53cbdb Mon Sep 17 00:00:00 2001 From: watany <76135106+watany-dev@users.noreply.github.com> Date: Sat, 25 Nov 2023 15:58:57 +0000 Subject: [PATCH 08/14] update integ --- .../integ-distribution-function.assets.json | 4 ++-- .../integ-distribution-function.template.json | 2 +- .../manifest.json | 2 +- .../integ.distribution-function-runtime.js.snapshot/tree.json | 2 +- .../test/integ.distribution-function-runtime.ts | 2 ++ 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.assets.json index a164e0f9439f9..eaec73d98c45d 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.assets.json @@ -1,7 +1,7 @@ { "version": "35.0.0", "files": { - "566341e5b3961d17fc2b60a44eba712f6e295016886f23ce22320d2c3a11f6bc": { + "5289568fbbfd952fddb41b828b4b0a8e4b54ec5892e158efd72cf494c0327e01": { "source": { "path": "integ-distribution-function.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-eu-west-1": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-eu-west-1", - "objectKey": "566341e5b3961d17fc2b60a44eba712f6e295016886f23ce22320d2c3a11f6bc.json", + "objectKey": "5289568fbbfd952fddb41b828b4b0a8e4b54ec5892e158efd72cf494c0327e01.json", "region": "eu-west-1", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-eu-west-1" } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.template.json index e8419a9b8ed44..1ea7e8f64f1fa 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/integ-distribution-function.template.json @@ -19,7 +19,7 @@ "FunctionCode": "function handler(event) { return event.response }", "FunctionConfig": { "Comment": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1", - "Runtime": "cloudfront-js-1.0" + "Runtime": "cloudfront-js-2.0" }, "Name": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1" } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/manifest.json index cc6443b92a879..a71b2eef33f91 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/manifest.json @@ -18,7 +18,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-eu-west-1", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-eu-west-1", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-eu-west-1/566341e5b3961d17fc2b60a44eba712f6e295016886f23ce22320d2c3a11f6bc.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-eu-west-1/5289568fbbfd952fddb41b828b4b0a8e4b54ec5892e158efd72cf494c0327e01.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/tree.json index 988c2366038c6..47bb430289c3b 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.js.snapshot/tree.json @@ -52,7 +52,7 @@ "functionCode": "function handler(event) { return event.response }", "functionConfig": { "comment": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1", - "runtime": "cloudfront-js-1.0" + "runtime": "cloudfront-js-2.0" }, "name": "eu-west-1integdistributionfunctionFunctionResponseDD4BADA1" } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts index 4359252deb8df..9ac8bcfe9e768 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts @@ -8,10 +8,12 @@ const stack = new cdk.Stack(app, 'integ-distribution-function', { env: { region: const cfFunctionRequest = new cloudfront.Function(stack, 'FunctionRequest', { code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'), + runtime: cloudfront.FunctionRuntime.JS_1_0, }); const cfFunctionResponse = new cloudfront.Function(stack, 'FunctionResponse', { code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.response }'), + runtime: cloudfront.FunctionRuntime.JS_2_0, }); new cloudfront.Distribution(stack, 'Dist', { From 7d82d0e0e781ead0c08bc8035827f066d839687a Mon Sep 17 00:00:00 2001 From: watany <76135106+watany-dev@users.noreply.github.com> Date: Thu, 21 Dec 2023 14:34:26 +0000 Subject: [PATCH 09/14] enum to class --- .../aws-cloudfront/lib/function.ts | 34 ++++++++++++++++--- .../aws-cloudfront/test/function.test.ts | 28 +++++++++++++++ 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts index 84390636a6528..3681a19946e84 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts @@ -100,6 +100,12 @@ export interface FunctionAttributes { * The ARN of the function. */ readonly functionArn: string; + + /** + * The Runtime of the function. + */ + readonly functionRuntime: string; + } /** @@ -142,6 +148,7 @@ export class Function extends Resource implements IFunction { return new class extends Resource implements IFunction { public readonly functionName = attrs.functionName; public readonly functionArn = attrs.functionArn; + public readonly functionRuntime = attrs.functionRuntime; }(scope, id); } @@ -160,18 +167,25 @@ export class Function extends Resource implements IFunction { * @attribute */ public readonly functionStage: string; + /** + * the runtime of the CloudFront function + * @attribute + */ + public readonly functionRuntime: string; constructor(scope: Construct, id: string, props: FunctionProps) { super(scope, id); this.functionName = props.functionName ?? this.generateName(); + this.functionRuntime = props.runtime?.value ?? FunctionRuntime.JS_1_0.value; + const resource = new CfnFunction(this, 'Resource', { autoPublish: true, functionCode: props.code.render(), functionConfig: { comment: props.comment ?? this.functionName, - runtime: props.runtime ?? FunctionRuntime.JS_1_0, + runtime: this.functionRuntime, }, name: this.functionName, }); @@ -222,15 +236,27 @@ export interface FunctionAssociation { /** * The function's runtime environment version. */ -export enum FunctionRuntime { +export class FunctionRuntime { /** * cloudfront-js-1.0 */ - JS_1_0 = 'cloudfront-js-1.0', + public static readonly JS_1_0 = new FunctionRuntime('cloudfront-js-1.0'); /** * cloudfront-js-2.0 */ - JS_2_0 = 'cloudfront-js-2.0', + public static readonly JS_2_0 = new FunctionRuntime('cloudfront-js-2.0'); + + /** + * A custom runtime string. + * + * Gives full control over the runtime string fragment. + */ + public static custom(runtimeString: string): FunctionRuntime { + return new FunctionRuntime(runtimeString); + } + + protected constructor(public readonly value: string) {} + } \ No newline at end of file diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/function.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/function.test.ts index 53fbdab55293b..142559b07ea7c 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/function.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/function.test.ts @@ -160,4 +160,32 @@ describe('CloudFront Function', () => { }, }); }); + + test('custom runtime testing', () => { + const app = new App(); + const stack = new Stack(app, 'Stack', { + env: { account: '123456789012', region: 'testregion' }, + }); + new Function(stack, 'CF2', { + code: FunctionCode.fromInline('code'), + runtime: FunctionRuntime.custom('cloudfront-js-2.0'), + }); + + Template.fromStack(stack).templateMatches({ + Resources: { + CF2D7241DD7: { + Type: 'AWS::CloudFront::Function', + Properties: { + Name: 'testregionStackCF2CE3F783F', + AutoPublish: true, + FunctionCode: 'code', + FunctionConfig: { + Comment: 'testregionStackCF2CE3F783F', + Runtime: 'cloudfront-js-2.0', + }, + }, + }, + }, + }); + }); }); From 18b4cfe4074fbcf9ad07562c25b2835269a242ca Mon Sep 17 00:00:00 2001 From: watany <76135106+watany-dev@users.noreply.github.com> Date: Thu, 21 Dec 2023 15:54:38 +0000 Subject: [PATCH 10/14] fix lint --- packages/aws-cdk-lib/awslint.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/aws-cdk-lib/awslint.json b/packages/aws-cdk-lib/awslint.json index 9f44fe0c02597..4798a4f3fc2fd 100644 --- a/packages/aws-cdk-lib/awslint.json +++ b/packages/aws-cdk-lib/awslint.json @@ -236,6 +236,7 @@ "docs-public-apis:aws-cdk-lib.aws_autoscaling.TargetTrackingScalingPolicy", "docs-public-apis:aws-cdk-lib.aws_cloudfront.ViewerCertificate.aliases", "docs-public-apis:aws-cdk-lib.aws_cloudfront.ViewerCertificate.props", + "docs-public-apis:aws-cdk-lib.aws_cloudfront.FunctionRuntime.value", "docs-public-apis:aws-cdk-lib.aws_cloudtrail.InsightType.value", "docs-public-apis:aws-cdk-lib.aws_cloudwatch.DefaultValue.val", "docs-public-apis:aws-cdk-lib.aws_cloudwatch.Values.toJson", From 170ea4b671f7b376eb95611b67a0644660191db3 Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <36202692+kaizencc@users.noreply.github.com> Date: Fri, 22 Dec 2023 13:56:51 -0800 Subject: [PATCH 11/14] Apply suggestions from code review --- packages/aws-cdk-lib/aws-cloudfront/lib/function.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts index 3681a19946e84..dbcc589c52e09 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts @@ -237,7 +237,6 @@ export interface FunctionAssociation { * The function's runtime environment version. */ export class FunctionRuntime { - /** * cloudfront-js-1.0 */ @@ -257,6 +256,5 @@ export class FunctionRuntime { return new FunctionRuntime(runtimeString); } - protected constructor(public readonly value: string) {} - -} \ No newline at end of file + private constructor(public readonly value: string) {} +} From 50e9ca5e0b45d723805472ed45d39e465e961a39 Mon Sep 17 00:00:00 2001 From: watany <76135106+watany-dev@users.noreply.github.com> Date: Thu, 28 Dec 2023 02:52:03 +0000 Subject: [PATCH 12/14] optional --- packages/aws-cdk-lib/aws-cloudfront/lib/function.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts index 3681a19946e84..1de43c1b714a1 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts @@ -104,7 +104,7 @@ export interface FunctionAttributes { /** * The Runtime of the function. */ - readonly functionRuntime: string; + readonly functionRuntime?: string; } @@ -148,7 +148,7 @@ export class Function extends Resource implements IFunction { return new class extends Resource implements IFunction { public readonly functionName = attrs.functionName; public readonly functionArn = attrs.functionArn; - public readonly functionRuntime = attrs.functionRuntime; + public readonly functionRuntime = attrs.functionRuntime ?? FunctionRuntime.JS_1_0.value; }(scope, id); } From b0eebba77e51a88bf444f19b1accef4d06f06dbf Mon Sep 17 00:00:00 2001 From: watany <76135106+watany-dev@users.noreply.github.com> Date: Thu, 28 Dec 2023 02:52:27 +0000 Subject: [PATCH 13/14] optional --- .pre-commit-config.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000000..aa94c88eb6de9 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,5 @@ +repos: + - repo: https://github.com/gitleaks/gitleaks + rev: v8.17.0 + hooks: + - id: gitleaks From 968fe513ebccc1b9d80677853fedc6058b284ed0 Mon Sep 17 00:00:00 2001 From: watany <76135106+watany-dev@users.noreply.github.com> Date: Thu, 28 Dec 2023 07:00:59 +0000 Subject: [PATCH 14/14] default --- packages/aws-cdk-lib/aws-cloudfront/lib/function.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts index 7cc2525a32cb9..71b874adb1934 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts @@ -103,6 +103,7 @@ export interface FunctionAttributes { /** * The Runtime of the function. + * @default FunctionRuntime.JS_1_0 */ readonly functionRuntime?: string;