Skip to content

Commit

Permalink
feat(cloudfront): associate key value stores to functions (aws#28571)
Browse files Browse the repository at this point in the history
CloudFormation now supports specifying [`KeyValueStoreAssocations`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-function-keyvaluestoreassociation.html) on a `AWS::CloudFront::Function`. This adds that support to the CDK. Even though the field is plural (in CloudFormation and the API), [a function can have one value store](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/kvs-with-functions-associate.html) so the implementation here tries to provide a nicer API around that.

If a Key Value Store is specified, the function will default to `js-2.0` instead of `js-1.0`. Behavior for existing functions is retained. Additionally, an error is thrown if 1.0 is used.

Closes aws#28377.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
kylelaker authored and Vandita2020 committed Jan 29, 2024
1 parent 586bb3f commit 2076e53
Show file tree
Hide file tree
Showing 13 changed files with 655 additions and 4 deletions.

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.

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,86 @@
{
"Resources": {
"TestKeyValueStore8D0C09A2": {
"Type": "AWS::CloudFront::KeyValueStore",
"Properties": {
"Comment": "A test Key Value Store for CloudFront",
"ImportSource": {
"SourceArn": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":s3:::",
{
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"/9c0f502203ec9d802046021b8a20affe8fd26234f67dcf2e93db5142bc2991a1.json"
]
]
},
"SourceType": "S3"
},
"Name": "integfunctionkeyvaluestoreassociationTestKeyValueStoreA8304A36"
}
},
"TestFunction22AD90FC": {
"Type": "AWS::CloudFront::Function",
"Properties": {
"AutoPublish": true,
"FunctionCode": "code",
"FunctionConfig": {
"Comment": "TestKvFunction",
"KeyValueStoreAssociations": [
{
"KeyValueStoreARN": {
"Fn::GetAtt": [
"TestKeyValueStore8D0C09A2",
"Arn"
]
}
}
],
"Runtime": "cloudfront-js-2.0"
},
"Name": "TestKvFunction"
}
}
},
"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.

0 comments on commit 2076e53

Please sign in to comment.