Skip to content

Commit

Permalink
feat(cloudfront): add autoPublish property to the Function (#30030)
Browse files Browse the repository at this point in the history
### 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*
  • Loading branch information
mazyu36 authored May 1, 2024
1 parent cbf130e commit 5dd72b8
Show file tree
Hide file tree
Showing 12 changed files with 432 additions and 1 deletion.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -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<String>",
"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."
}
]
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5dd72b8

Please sign in to comment.