Skip to content

Commit 5dd72b8

Browse files
authored
feat(cloudfront): add autoPublish property to the Function (#30030)
### 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*
1 parent cbf130e commit 5dd72b8

12 files changed

+432
-1
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/AutoPublishTestDefaultTestDeployAssert10053C6C.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/AutoPublishTestDefaultTestDeployAssert10053C6C.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/cdk.out

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/integ-distribution-function.assets.json

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"Resources": {
3+
"functionF19B1A04": {
4+
"Type": "AWS::CloudFront::Function",
5+
"Properties": {
6+
"AutoPublish": false,
7+
"FunctionCode": "function handler(event) { return event.request }",
8+
"FunctionConfig": {
9+
"Comment": "eu-west-1integdistributionfunctionEBF560BA",
10+
"Runtime": "cloudfront-js-1.0"
11+
},
12+
"Name": "eu-west-1integdistributionfunctionEBF560BA"
13+
}
14+
}
15+
},
16+
"Parameters": {
17+
"BootstrapVersion": {
18+
"Type": "AWS::SSM::Parameter::Value<String>",
19+
"Default": "/cdk-bootstrap/hnb659fds/version",
20+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
21+
}
22+
},
23+
"Rules": {
24+
"CheckBootstrapVersion": {
25+
"Assertions": [
26+
{
27+
"Assert": {
28+
"Fn::Not": [
29+
{
30+
"Fn::Contains": [
31+
[
32+
"1",
33+
"2",
34+
"3",
35+
"4",
36+
"5"
37+
],
38+
{
39+
"Ref": "BootstrapVersion"
40+
}
41+
]
42+
}
43+
]
44+
},
45+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
46+
}
47+
]
48+
}
49+
}
50+
}

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/integ.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/manifest.json

+113
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-autopublish.js.snapshot/tree.json

+131
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)