From 5dd72b89f20b1246ad125440e42449acd80c8be7 Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Thu, 2 May 2024 07:19:48 +0900 Subject: [PATCH] feat(cloudfront): add `autoPublish` property to the `Function` (#30030) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Issue # (if applicable) Closes #30028 ### Reason for this change As described in the issue. ### Description of changes In this pull request, the "autoPublish" Property has been added to the Function class. If you set `autoPublish` to false, the function will not be automatically published to the LIVE stage when it’s created. ```ts new cloudfront.Function(this, 'Function', { code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'), runtime: cloudfront.FunctionRuntime.JS_2_0, autoPublish: false // Add }); ``` To ensure that the behavior remains unchanged when autoPublish is not set, the field is optional, with the default value set to true. ### Description of how you validated changes I've added unit and integ tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- ...efaultTestDeployAssert10053C6C.assets.json | 19 +++ ...aultTestDeployAssert10053C6C.template.json | 36 +++++ .../cdk.out | 1 + .../integ-distribution-function.assets.json | 20 +++ .../integ-distribution-function.template.json | 50 +++++++ .../integ.json | 12 ++ .../manifest.json | 113 +++++++++++++++ .../tree.json | 131 ++++++++++++++++++ ...integ.distribution-function-autopublish.ts | 17 +++ packages/aws-cdk-lib/aws-cloudfront/README.md | 10 ++ .../aws-cloudfront/lib/function.ts | 9 +- .../aws-cloudfront/test/function.test.ts | 15 ++ 12 files changed, 432 insertions(+), 1 deletion(-) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/AutoPublishTestDefaultTestDeployAssert10053C6C.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/AutoPublishTestDefaultTestDeployAssert10053C6C.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/integ-distribution-function.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/integ-distribution-function.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/tree.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/AutoPublishTestDefaultTestDeployAssert10053C6C.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/AutoPublishTestDefaultTestDeployAssert10053C6C.assets.json new file mode 100644 index 0000000000000..f902b44487802 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/AutoPublishTestDefaultTestDeployAssert10053C6C.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "AutoPublishTestDefaultTestDeployAssert10053C6C.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-autopublish.js.snapshot/AutoPublishTestDefaultTestDeployAssert10053C6C.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/AutoPublishTestDefaultTestDeployAssert10053C6C.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-autopublish.js.snapshot/AutoPublishTestDefaultTestDeployAssert10053C6C.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-autopublish.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/cdk.out new file mode 100644 index 0000000000000..1f0068d32659a --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"36.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/integ-distribution-function.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/integ-distribution-function.assets.json new file mode 100644 index 0000000000000..c27a51da14229 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/integ-distribution-function.assets.json @@ -0,0 +1,20 @@ +{ + "version": "36.0.0", + "files": { + "1dda42468200b80edf117a21fed6815e728d5604142186ccedaab4032c896305": { + "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": "1dda42468200b80edf117a21fed6815e728d5604142186ccedaab4032c896305.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-autopublish.js.snapshot/integ-distribution-function.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/integ-distribution-function.template.json new file mode 100644 index 0000000000000..b05f54497f4cc --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/integ-distribution-function.template.json @@ -0,0 +1,50 @@ +{ + "Resources": { + "functionF19B1A04": { + "Type": "AWS::CloudFront::Function", + "Properties": { + "AutoPublish": false, + "FunctionCode": "function handler(event) { return event.request }", + "FunctionConfig": { + "Comment": "eu-west-1integdistributionfunctionEBF560BA", + "Runtime": "cloudfront-js-1.0" + }, + "Name": "eu-west-1integdistributionfunctionEBF560BA" + } + } + }, + "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-autopublish.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/integ.json new file mode 100644 index 0000000000000..55d83514a5800 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "36.0.0", + "testCases": { + "AutoPublishTest/DefaultTest": { + "stacks": [ + "integ-distribution-function" + ], + "assertionStack": "AutoPublishTest/DefaultTest/DeployAssert", + "assertionStackName": "AutoPublishTestDefaultTestDeployAssert10053C6C" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/manifest.json new file mode 100644 index 0000000000000..05c74b232048c --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/manifest.json @@ -0,0 +1,113 @@ +{ + "version": "36.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/1dda42468200b80edf117a21fed6815e728d5604142186ccedaab4032c896305.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/function/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "functionF19B1A04" + } + ], + "/integ-distribution-function/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/integ-distribution-function/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "integ-distribution-function" + }, + "AutoPublishTestDefaultTestDeployAssert10053C6C.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "AutoPublishTestDefaultTestDeployAssert10053C6C.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "AutoPublishTestDefaultTestDeployAssert10053C6C": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "AutoPublishTestDefaultTestDeployAssert10053C6C.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": [ + "AutoPublishTestDefaultTestDeployAssert10053C6C.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": [ + "AutoPublishTestDefaultTestDeployAssert10053C6C.assets" + ], + "metadata": { + "/AutoPublishTest/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/AutoPublishTest/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "AutoPublishTest/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-autopublish.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/tree.json new file mode 100644 index 0000000000000..9a413b8eff14c --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/tree.json @@ -0,0 +1,131 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "integ-distribution-function": { + "id": "integ-distribution-function", + "path": "integ-distribution-function", + "children": { + "function": { + "id": "function", + "path": "integ-distribution-function/function", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-distribution-function/function/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CloudFront::Function", + "aws:cdk:cloudformation:props": { + "autoPublish": false, + "functionCode": "function handler(event) { return event.request }", + "functionConfig": { + "comment": "eu-west-1integdistributionfunctionEBF560BA", + "runtime": "cloudfront-js-1.0" + }, + "name": "eu-west-1integdistributionfunctionEBF560BA" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudfront.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudfront.Function", + "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" + } + }, + "AutoPublishTest": { + "id": "AutoPublishTest", + "path": "AutoPublishTest", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "AutoPublishTest/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "AutoPublishTest/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "AutoPublishTest/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "AutoPublishTest/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "AutoPublishTest/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 diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.ts new file mode 100644 index 0000000000000..a45d48ec278fe --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.ts @@ -0,0 +1,17 @@ +import * as cdk from 'aws-cdk-lib'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; +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' } }); + +new cloudfront.Function(stack, 'function', { + code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'), + autoPublish: false, +}); + +new IntegTest(app, 'AutoPublishTest', { + testCases: [stack], +}); + +app.synth(); diff --git a/packages/aws-cdk-lib/aws-cloudfront/README.md b/packages/aws-cdk-lib/aws-cloudfront/README.md index 9d09b96e99906..673daa77f052d 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/README.md +++ b/packages/aws-cdk-lib/aws-cloudfront/README.md @@ -537,6 +537,16 @@ It will auto-generate the name of the function and deploy it to the `live` stage Additionally, you can load the function's code from a file using the `FunctionCode.fromFile()` method. +If you set `autoPublish` to false, the function will not be automatically published to the LIVE stage when it’s created. + +``ts +new cloudfront.Function(this, 'Function', { + code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'), + runtime: cloudfront.FunctionRuntime.JS_2_0, + autoPublish: false +}); +``` + ### Key Value Store A CloudFront Key Value Store can be created and optionally have data imported from a JSON file diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts index bdf72350b689e..e14a1f53c5cf7 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts @@ -146,6 +146,13 @@ export interface FunctionProps { * @default - no key value store is associated */ readonly keyValueStore?: IKeyValueStore; + + /** + * A flag that determines whether to automatically publish the function to the LIVE stage when it’s created. + * + * @default - true + */ + readonly autoPublish?: boolean; } /** @@ -200,7 +207,7 @@ export class Function extends Resource implements IFunction { } const resource = new CfnFunction(this, 'Resource', { - autoPublish: true, + autoPublish: props.autoPublish ?? true, functionCode: props.code.render(), functionConfig: { comment: props.comment ?? this.functionName, 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 5e17a59362535..38072b8614bd2 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/function.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/function.test.ts @@ -189,6 +189,21 @@ describe('CloudFront Function', () => { }); }); + test('autoPublish false', () => { + const stack = new Stack(); + + new Function(stack, 'TestFn', { + code: FunctionCode.fromInline('code'), + runtime: FunctionRuntime.JS_2_0, + keyValueStore: undefined, + autoPublish: false, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::CloudFront::Function', { + AutoPublish: false, + }); + }); + describe('key value store association', () => { test('minimal example', () => { const stack = new Stack();