Skip to content

Commit 5675010

Browse files
authored
feat(cloudfront): adding support for inline KeyValueStore sources (#29419)
### Issue # (if applicable) Closes #29204. ### Reason for this change CloudFront's `KeyValueStore` has the option to initialize the store using a file, imported with an `ImportSource`. The CloudFormation resource does not support inline declarations, so the current L2 construct does not support inline either. To provide easier ### Description of changes Added the `InlineImportSource`, along with the companion static method to `cloudfront.KeyValueStore`. #### 📄 Temporary Files Since inline declarations are not supported by the underlying L1 construct, I have resorted to creating a temporary file which will be handled as a CDK asset. This is done utilizing elements of the cdk core, and follows the pattern used by the `s3-deployment`. This does also couple the KeyValueStore to the assets in S3, though the only other option would seem to be creating its own S3 bucket. This is the only case I'm aware of in CDK of handling a temporary file like this. As far as I'm aware, all design principles are met, but this seems something of an edge case. Open to suggestions and reviews. ### Description of how you validated changes New Unit Tests and Integration Test implemented ### 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 abb5af6 commit 5675010

File tree

18 files changed

+978
-5
lines changed

18 files changed

+978
-5
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.key-value-store-frominline.js.snapshot/KeyValueStoreDefaultTestDeployAssert87336A31.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.key-value-store-frominline.js.snapshot/KeyValueStoreDefaultTestDeployAssert87336A31.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.key-value-store-frominline.js.snapshot/asset.47ae18762663e5017f1b901bfe0a06cb436df2476a53b49e1db53fc36a08a793.json

+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.key-value-store-frominline.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.key-value-store-frominline.js.snapshot/integ-key-value-store.assets.json

+32
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,64 @@
1+
{
2+
"Resources": {
3+
"TestKeyValueStore8D0C09A2": {
4+
"Type": "AWS::CloudFront::KeyValueStore",
5+
"Properties": {
6+
"Comment": "A test Key Value Store for CloudFront",
7+
"ImportSource": {
8+
"SourceArn": {
9+
"Fn::Join": [
10+
"",
11+
[
12+
"arn:",
13+
{
14+
"Ref": "AWS::Partition"
15+
},
16+
":s3:::",
17+
{
18+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
19+
},
20+
"/47ae18762663e5017f1b901bfe0a06cb436df2476a53b49e1db53fc36a08a793.json"
21+
]
22+
]
23+
},
24+
"SourceType": "S3"
25+
},
26+
"Name": "integkeyvaluestoreTestKeyValueStore737B4C4B"
27+
}
28+
}
29+
},
30+
"Parameters": {
31+
"BootstrapVersion": {
32+
"Type": "AWS::SSM::Parameter::Value<String>",
33+
"Default": "/cdk-bootstrap/hnb659fds/version",
34+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
35+
}
36+
},
37+
"Rules": {
38+
"CheckBootstrapVersion": {
39+
"Assertions": [
40+
{
41+
"Assert": {
42+
"Fn::Not": [
43+
{
44+
"Fn::Contains": [
45+
[
46+
"1",
47+
"2",
48+
"3",
49+
"4",
50+
"5"
51+
],
52+
{
53+
"Ref": "BootstrapVersion"
54+
}
55+
]
56+
}
57+
]
58+
},
59+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
60+
}
61+
]
62+
}
63+
}
64+
}

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.key-value-store-frominline.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.key-value-store-frominline.js.snapshot/manifest.json

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

0 commit comments

Comments
 (0)