@kensio/yulin 1.20.17 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/service/athena/engine/sim-athena-comparison-shims.d.ts +13 -0
- package/dist/service/athena/engine/sim-athena-comparison-shims.js +68 -0
- package/dist/service/athena/engine/sim-athena-shims.js +2 -0
- package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-cfn-value-adapter.js +8 -0
- package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-orp-cfn.d.ts +24 -0
- package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-orp-cfn.js +31 -0
- package/dist/service/cloudfront/behaviour/sim-cloud-front-behavior.d.ts +12 -1
- package/dist/service/cloudfront/cache/sim-cf-accept-encoding.d.ts +11 -0
- package/dist/service/cloudfront/cache/sim-cf-accept-encoding.js +27 -0
- package/dist/service/cloudfront/cache/sim-cf-cache-control.d.ts +28 -0
- package/dist/service/cloudfront/cache/sim-cf-cache-control.js +49 -0
- package/dist/service/cloudfront/cache/sim-cf-cache-entry-key-path.d.ts +11 -0
- package/dist/service/cloudfront/cache/sim-cf-cache-entry-key-path.js +22 -0
- package/dist/service/cloudfront/cache/sim-cf-cache-entry-key.d.ts +32 -0
- package/dist/service/cloudfront/cache/sim-cf-cache-entry-key.js +112 -0
- package/dist/service/cloudfront/cache/sim-cf-cache-status.d.ts +27 -0
- package/dist/service/cloudfront/cache/sim-cf-cache-status.js +53 -0
- package/dist/service/cloudfront/cache/sim-cf-cache-ttl.d.ts +28 -0
- package/dist/service/cloudfront/cache/sim-cf-cache-ttl.js +50 -0
- package/dist/service/cloudfront/cache/sim-cf-cacheable-request.d.ts +35 -0
- package/dist/service/cloudfront/cache/sim-cf-cacheable-request.js +32 -0
- package/dist/service/cloudfront/cache/sim-cf-distribution-cache.d.ts +57 -0
- package/dist/service/cloudfront/cache/sim-cf-distribution-cache.js +115 -0
- package/dist/service/cloudfront/cache/sim-cf-edge.d.ts +37 -0
- package/dist/service/cloudfront/cache/sim-cf-edge.js +34 -0
- package/dist/service/cloudfront/cache/sim-cf-error-cache-ttl.d.ts +36 -0
- package/dist/service/cloudfront/cache/sim-cf-error-cache-ttl.js +28 -0
- package/dist/service/cloudfront/cache/sim-cf-http-date.d.ts +15 -0
- package/dist/service/cloudfront/cache/sim-cf-http-date.js +40 -0
- package/dist/service/cloudfront/cache-policy/sim-cf-cache-key.d.ts +63 -0
- package/dist/service/cloudfront/cache-policy/sim-cf-cache-key.js +70 -0
- package/dist/service/cloudfront/cache-policy/sim-cf-cache-policy.d.ts +13 -3
- package/dist/service/cloudfront/cache-policy/sim-cf-cache-policy.js +31 -3
- package/dist/service/cloudfront/cache-policy/sim-cf-managed-cache-policies.d.ts +8 -3
- package/dist/service/cloudfront/cache-policy/sim-cf-managed-cache-policies.js +96 -12
- package/dist/service/cloudfront/cff/sim-cff-search-distribution.fixture.js +4 -0
- package/dist/service/cloudfront/cfn/cache-policy/sim-cfn-cf-cache-policy-config.d.ts +9 -8
- package/dist/service/cloudfront/cfn/cache-policy/sim-cfn-cf-cache-policy-config.js +40 -11
- package/dist/service/cloudfront/cfn/cache-policy/sim-cfn-cf-cache-policy-key.d.ts +10 -0
- package/dist/service/cloudfront/cfn/cache-policy/sim-cfn-cf-cache-policy-key.js +50 -0
- package/dist/service/cloudfront/cfn/cache-policy/sim-cfn-cf-cache-policy-section.d.ts +28 -0
- package/dist/service/cloudfront/cfn/cache-policy/sim-cfn-cf-cache-policy-section.js +29 -0
- package/dist/service/cloudfront/cfn/distro/sim-cfn-cf-behavior-policy-kinds.d.ts +16 -0
- package/dist/service/cloudfront/cfn/distro/sim-cfn-cf-behavior-policy-kinds.js +23 -0
- package/dist/service/cloudfront/cfn/distro/sim-cfn-cf-distro-behavior-policies.d.ts +3 -2
- package/dist/service/cloudfront/cfn/distro/sim-cfn-cf-distro-behavior-policies.js +3 -2
- package/dist/service/cloudfront/cfn/distro/sim-cfn-cf-distro-creator.d.ts +6 -6
- package/dist/service/cloudfront/cfn/distro/sim-cfn-cf-distro-creator.js +6 -6
- package/dist/service/cloudfront/cfn/distro/sim-cfn-cf-distro-policy-drops.js +8 -23
- package/dist/service/cloudfront/cfn/origin-request-policy/sim-cfn-cf-orp-config.d.ts +28 -0
- package/dist/service/cloudfront/cfn/origin-request-policy/sim-cfn-cf-orp-config.js +46 -0
- package/dist/service/cloudfront/cfn/origin-request-policy/sim-cfn-cf-orp-creator.d.ts +24 -0
- package/dist/service/cloudfront/cfn/origin-request-policy/sim-cfn-cf-orp-creator.js +32 -0
- package/dist/service/cloudfront/cfn/origin-request-policy/sim-cfn-cf-orp-forwarding.d.ts +10 -0
- package/dist/service/cloudfront/cfn/origin-request-policy/sim-cfn-cf-orp-forwarding.js +51 -0
- package/dist/service/cloudfront/cfn/policy/sim-cfn-cf-policy-section.d.ts +22 -0
- package/dist/service/cloudfront/cfn/policy/sim-cfn-cf-policy-section.js +54 -0
- package/dist/service/cloudfront/cfn/sim-cfn-cloudfront-resource-factory.d.ts +1 -0
- package/dist/service/cloudfront/cfn/sim-cfn-cloudfront-resource-factory.js +12 -0
- package/dist/service/cloudfront/command/create-distribution/create-distribution.command.d.ts +1 -0
- package/dist/service/cloudfront/command/create-distribution/create-distribution.handler.d.ts +2 -0
- package/dist/service/cloudfront/command/invalidation/sim-cf-create-invalidation.d.ts +28 -0
- package/dist/service/cloudfront/command/invalidation/sim-cf-create-invalidation.js +59 -0
- package/dist/service/cloudfront/command/invalidation/sim-cf-get-invalidation.d.ts +19 -0
- package/dist/service/cloudfront/command/invalidation/sim-cf-get-invalidation.js +32 -0
- package/dist/service/cloudfront/command/invalidation/sim-cf-invalidation-access.d.ts +36 -0
- package/dist/service/cloudfront/command/invalidation/sim-cf-invalidation-access.js +45 -0
- package/dist/service/cloudfront/command/invalidation/sim-cf-invalidation-command.types.d.ts +80 -0
- package/dist/service/cloudfront/command/invalidation/sim-cf-invalidation-command.types.js +1 -0
- package/dist/service/cloudfront/command/invalidation/sim-cf-invalidation-commands.d.ts +39 -0
- package/dist/service/cloudfront/command/invalidation/sim-cf-invalidation-commands.js +35 -0
- package/dist/service/cloudfront/command/invalidation/sim-cf-list-invalidations.d.ts +23 -0
- package/dist/service/cloudfront/command/invalidation/sim-cf-list-invalidations.js +39 -0
- package/dist/service/cloudfront/command/update-distribution/update-distribution.handler.d.ts +2 -0
- package/dist/service/cloudfront/controller/content/sim-cf-content-stage.d.ts +51 -0
- package/dist/service/cloudfront/controller/content/sim-cf-content-stage.js +65 -0
- package/dist/service/cloudfront/controller/dependency/sim-cf-controller-dependency.d.ts +2 -3
- package/dist/service/cloudfront/controller/dependency/sim-cf-controller-dependency.js +4 -4
- package/dist/service/cloudfront/controller/error/sim-cf-custom-error-responder.d.ts +4 -0
- package/dist/service/cloudfront/controller/error/sim-cf-custom-error-responder.js +12 -8
- package/dist/service/cloudfront/controller/origin/sim-cf-origin-stage.d.ts +2 -2
- package/dist/service/cloudfront/controller/origin/sim-cf-origin-stage.js +2 -2
- package/dist/service/cloudfront/controller/sim-cloudfront-request-pipeline.d.ts +6 -6
- package/dist/service/cloudfront/controller/sim-cloudfront-request-pipeline.js +35 -20
- package/dist/service/cloudfront/custom-error/sim-cloudfront-custom-error-response.d.ts +23 -5
- package/dist/service/cloudfront/custom-error/sim-cloudfront-custom-error-response.js +8 -0
- package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-origin-request-policy.d.ts +18 -0
- package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-origin-request-policy.js +30 -0
- package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-policies.d.ts +7 -5
- package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-policies.js +8 -5
- package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-properties.js +4 -1
- package/dist/service/cloudfront/distribution/configurator/sim-cf-distribution-configurator.factory.d.ts +2 -0
- package/dist/service/cloudfront/distribution/configurator/sim-cf-distribution-configurator.factory.js +6 -2
- package/dist/service/cloudfront/distribution/configurator/sim-cloud-front-custom-error-configurator.d.ts +13 -3
- package/dist/service/cloudfront/distribution/configurator/sim-cloud-front-custom-error-configurator.js +27 -6
- package/dist/service/cloudfront/distribution/configurator/sim-cloud-front-origin-configurator.d.ts +3 -1
- package/dist/service/cloudfront/distribution/configurator/sim-cloud-front-origin-configurator.js +4 -1
- package/dist/service/cloudfront/distribution/sim-cf-distribution-configuration-state.d.ts +5 -3
- package/dist/service/cloudfront/distribution/sim-cf-distribution-reconfigurer.d.ts +2 -0
- package/dist/service/cloudfront/distribution/sim-cf-distribution-view.js +1 -1
- package/dist/service/cloudfront/distribution/sim-cloudfront-distribution.d.ts +25 -2
- package/dist/service/cloudfront/distribution/sim-cloudfront-distribution.js +24 -0
- package/dist/service/cloudfront/error/sim-cf-invalidation.error.d.ts +22 -0
- package/dist/service/cloudfront/error/sim-cf-invalidation.error.js +26 -0
- package/dist/service/cloudfront/error/sim-cf-origin-request-policy.error.d.ts +22 -0
- package/dist/service/cloudfront/error/sim-cf-origin-request-policy.error.js +26 -0
- package/dist/service/cloudfront/index.d.ts +2 -0
- package/dist/service/cloudfront/index.js +1 -0
- package/dist/service/cloudfront/invalidation/sim-cf-invalidation-path.d.ts +22 -0
- package/dist/service/cloudfront/invalidation/sim-cf-invalidation-path.js +32 -0
- package/dist/service/cloudfront/invalidation/sim-cf-invalidation-view.d.ts +43 -0
- package/dist/service/cloudfront/invalidation/sim-cf-invalidation-view.js +33 -0
- package/dist/service/cloudfront/invalidation/sim-cf-invalidation.d.ts +55 -0
- package/dist/service/cloudfront/invalidation/sim-cf-invalidation.js +56 -0
- package/dist/service/cloudfront/invalidation/sim-cf-invalidations.d.ts +41 -0
- package/dist/service/cloudfront/invalidation/sim-cf-invalidations.js +58 -0
- package/dist/service/cloudfront/invalidation/sim-cf-repeated-invalidation.d.ts +15 -0
- package/dist/service/cloudfront/invalidation/sim-cf-repeated-invalidation.js +23 -0
- package/dist/service/cloudfront/origin/custom/sim-cf-custom-origin-forwarding.d.ts +19 -0
- package/dist/service/cloudfront/origin/custom/sim-cf-custom-origin-forwarding.js +116 -0
- package/dist/service/cloudfront/origin/custom/sim-cf-custom-origin-request.d.ts +15 -5
- package/dist/service/cloudfront/origin/custom/sim-cf-custom-origin-request.js +13 -8
- package/dist/service/cloudfront/origin/custom/sim-cf-custom-origin-signer.js +8 -5
- package/dist/service/cloudfront/origin/custom/sim-cloudfront-custom-origin.d.ts +13 -0
- package/dist/service/cloudfront/origin/custom/sim-cloudfront-custom-origin.js +8 -0
- package/dist/service/cloudfront/origin-request-policy/sim-cf-behavior-forwarded.d.ts +24 -0
- package/dist/service/cloudfront/origin-request-policy/sim-cf-behavior-forwarded.js +21 -0
- package/dist/service/cloudfront/origin-request-policy/sim-cf-forwarded-to-origin.d.ts +57 -0
- package/dist/service/cloudfront/origin-request-policy/sim-cf-forwarded-to-origin.js +129 -0
- package/dist/service/cloudfront/origin-request-policy/sim-cf-managed-origin-request-policies.d.ts +30 -0
- package/dist/service/cloudfront/origin-request-policy/sim-cf-managed-origin-request-policies.js +121 -0
- package/dist/service/cloudfront/origin-request-policy/sim-cf-origin-request-forwarding.d.ts +56 -0
- package/dist/service/cloudfront/origin-request-policy/sim-cf-origin-request-forwarding.js +67 -0
- package/dist/service/cloudfront/origin-request-policy/sim-cf-origin-request-policy-registry.d.ts +38 -0
- package/dist/service/cloudfront/origin-request-policy/sim-cf-origin-request-policy-registry.js +51 -0
- package/dist/service/cloudfront/origin-request-policy/sim-cf-origin-request-policy.d.ts +32 -0
- package/dist/service/cloudfront/origin-request-policy/sim-cf-origin-request-policy.js +30 -0
- package/dist/service/cloudfront/registry/sim-cloud-front-registry.d.ts +25 -0
- package/dist/service/cloudfront/registry/sim-cloud-front-registry.js +23 -0
- package/dist/service/cloudfront/sdk/sim-cloudfront-sdk-command-router.js +12 -0
- package/dist/service/cloudfront/sim-cloudfront-caching.d.ts +31 -0
- package/dist/service/cloudfront/sim-cloudfront-caching.js +38 -0
- package/dist/service/cloudfront/sim-cloudfront-commands.d.ts +12 -0
- package/dist/service/cloudfront/sim-cloudfront-commands.js +12 -0
- package/dist/service/cloudfront/sim-cloudfront-distributions.d.ts +21 -0
- package/dist/service/cloudfront/sim-cloudfront-distributions.js +23 -0
- package/dist/service/cloudfront/sim-cloudfront-origin-access-controls.d.ts +30 -0
- package/dist/service/cloudfront/sim-cloudfront-origin-access-controls.js +35 -0
- package/dist/service/cloudfront/sim-cloudfront-policies.d.ts +22 -5
- package/dist/service/cloudfront/sim-cloudfront-policies.js +27 -5
- package/dist/service/cloudfront/sim-cloudfront.d.ts +15 -31
- package/dist/service/cloudfront/sim-cloudfront.js +23 -41
- package/dist/service/iam/authorize/allow/sim-iam-allow-requirement.d.ts +6 -5
- package/dist/service/iam/authorize/allow/sim-iam-allow-requirement.js +6 -5
- package/dist/service/iam/authorize/context/sim-iam-auth-z-input.d.ts +6 -4
- package/dist/service/kms/command/sim-kms-request-options.d.ts +9 -5
- package/dist/service/logs/command/delivery/sim-logs-delivery-source-commands.d.ts +6 -4
- package/dist/service/logs/command/delivery/sim-logs-delivery-source-commands.js +13 -4
- package/dist/service/logs/delivery/cloudfront/sim-logs-vended-log-delivery.d.ts +23 -0
- package/dist/service/logs/delivery/cloudfront/sim-logs-vended-log-delivery.js +28 -0
- package/dist/service/ssm/parameter/sim-ssm-kms-crypto.d.ts +7 -10
- package/dist/service/ssm/parameter/sim-ssm-parameter-kms.d.ts +10 -11
- package/dist/service/ssm/parameter/sim-ssm-parameter-kms.js +11 -16
- package/docs/services/athena/README.md +7 -1
- package/docs/services/cloudformation/README.md +2 -1
- package/docs/services/cloudfront/README.md +903 -25
- package/docs/services/ecs/README.md +5 -2
- package/docs/services/kms/README.md +9 -5
- package/docs/services/logs/README.md +6 -0
- package/docs/services/ssm/README.md +26 -33
- package/package.json +1 -1
|
@@ -19,9 +19,14 @@ export declare const simCfManagedCachePolicyIds: {
|
|
|
19
19
|
* The seven managed cache policies, built fresh for one simulated CloudFront.
|
|
20
20
|
*
|
|
21
21
|
* CloudFront owns these and every account has them, so a Behavior can name one
|
|
22
|
-
* without a template creating anything. Each carries the ID
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* without a template creating anything. Each carries the ID, the name, the
|
|
23
|
+
* TTLs and the cache key AWS publishes for it, so a Behavior on
|
|
24
|
+
* `CachingOptimized` here holds what one in an account holds.
|
|
25
|
+
*
|
|
26
|
+
* The normalized `Accept-Encoding` header AWS lists in some of these keys is
|
|
27
|
+
* not a header name in the whitelist. It is what the two `EnableAcceptEncoding`
|
|
28
|
+
* flags put in the key, which is why a policy carrying no header at all still
|
|
29
|
+
* caches a compressed object apart from an uncompressed one.
|
|
25
30
|
*
|
|
26
31
|
* https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html
|
|
27
32
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SimCloudFrontCacheKey } from "./sim-cf-cache-key.js";
|
|
1
2
|
import { SimCloudFrontCachePolicy, } from "./sim-cf-cache-policy.js";
|
|
2
3
|
/**
|
|
3
4
|
* The IDs AWS publishes for its managed cache policies.
|
|
@@ -15,34 +16,117 @@ export const simCfManagedCachePolicyIds = {
|
|
|
15
16
|
useOriginCacheControlHeaders: "83da9c7e-98b4-4e11-a168-04f0df8e2c65",
|
|
16
17
|
useOriginCacheControlHeadersQueryStrings: "4cc15a8a-d715-48a4-82b8-cc0b614638fe",
|
|
17
18
|
};
|
|
19
|
+
const daySeconds = 86_400;
|
|
20
|
+
const yearSeconds = 31_536_000;
|
|
21
|
+
/**
|
|
22
|
+
* The headers the two UseOriginCacheControlHeaders policies key on. They
|
|
23
|
+
* differ from each other in their query strings alone.
|
|
24
|
+
*/
|
|
25
|
+
const originCacheControlHeaders = [
|
|
26
|
+
"Host",
|
|
27
|
+
"Origin",
|
|
28
|
+
"X-HTTP-Method-Override",
|
|
29
|
+
"X-HTTP-Method",
|
|
30
|
+
"X-Method-Override",
|
|
31
|
+
];
|
|
18
32
|
/**
|
|
19
33
|
* The seven managed cache policies, built fresh for one simulated CloudFront.
|
|
20
34
|
*
|
|
21
35
|
* CloudFront owns these and every account has them, so a Behavior can name one
|
|
22
|
-
* without a template creating anything. Each carries the ID
|
|
23
|
-
*
|
|
24
|
-
*
|
|
36
|
+
* without a template creating anything. Each carries the ID, the name, the
|
|
37
|
+
* TTLs and the cache key AWS publishes for it, so a Behavior on
|
|
38
|
+
* `CachingOptimized` here holds what one in an account holds.
|
|
39
|
+
*
|
|
40
|
+
* The normalized `Accept-Encoding` header AWS lists in some of these keys is
|
|
41
|
+
* not a header name in the whitelist. It is what the two `EnableAcceptEncoding`
|
|
42
|
+
* flags put in the key, which is why a policy carrying no header at all still
|
|
43
|
+
* caches a compressed object apart from an uncompressed one.
|
|
25
44
|
*
|
|
26
45
|
* https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html
|
|
27
46
|
*/
|
|
28
47
|
export function simCfManagedCachePolicies() {
|
|
29
48
|
const policies = [
|
|
30
|
-
managedCachePolicy(simCfManagedCachePolicyIds.amplify, "Amplify"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
49
|
+
managedCachePolicy(simCfManagedCachePolicyIds.amplify, "Amplify", {
|
|
50
|
+
minTtlSec: 2,
|
|
51
|
+
defaultTtlSec: 2,
|
|
52
|
+
maxTtlSec: 600,
|
|
53
|
+
cacheKey: new SimCloudFrontCacheKey({
|
|
54
|
+
cookieBehavior: "all",
|
|
55
|
+
headerBehavior: "whitelist",
|
|
56
|
+
headers: ["Authorization", "CloudFront-Viewer-Country", "Host"],
|
|
57
|
+
queryStringBehavior: "all",
|
|
58
|
+
enableAcceptEncodingGzip: true,
|
|
59
|
+
enableAcceptEncodingBrotli: true,
|
|
60
|
+
}),
|
|
61
|
+
}),
|
|
62
|
+
managedCachePolicy(simCfManagedCachePolicyIds.cachingOptimized, "CachingOptimized", {
|
|
63
|
+
minTtlSec: 1,
|
|
64
|
+
defaultTtlSec: daySeconds,
|
|
65
|
+
maxTtlSec: yearSeconds,
|
|
66
|
+
cacheKey: new SimCloudFrontCacheKey({
|
|
67
|
+
enableAcceptEncodingGzip: true,
|
|
68
|
+
enableAcceptEncodingBrotli: true,
|
|
69
|
+
}),
|
|
70
|
+
}),
|
|
71
|
+
managedCachePolicy(simCfManagedCachePolicyIds.cachingOptimizedForUncompressedObjects, "CachingOptimizedForUncompressedObjects", {
|
|
72
|
+
minTtlSec: 1,
|
|
73
|
+
defaultTtlSec: daySeconds,
|
|
74
|
+
maxTtlSec: yearSeconds,
|
|
75
|
+
cacheKey: new SimCloudFrontCacheKey(),
|
|
76
|
+
}),
|
|
77
|
+
managedCachePolicy(simCfManagedCachePolicyIds.cachingDisabled, "CachingDisabled", {
|
|
78
|
+
minTtlSec: 0,
|
|
79
|
+
defaultTtlSec: 0,
|
|
80
|
+
maxTtlSec: 0,
|
|
81
|
+
cacheKey: new SimCloudFrontCacheKey(),
|
|
82
|
+
}),
|
|
83
|
+
managedCachePolicy(simCfManagedCachePolicyIds.elementalMediaPackage, "Elemental-MediaPackage", {
|
|
84
|
+
minTtlSec: 0,
|
|
85
|
+
defaultTtlSec: daySeconds,
|
|
86
|
+
maxTtlSec: yearSeconds,
|
|
87
|
+
cacheKey: new SimCloudFrontCacheKey({
|
|
88
|
+
headerBehavior: "whitelist",
|
|
89
|
+
headers: ["Origin"],
|
|
90
|
+
queryStringBehavior: "whitelist",
|
|
91
|
+
queryStrings: ["aws.manifestfilter", "start", "end", "m"],
|
|
92
|
+
enableAcceptEncodingGzip: true,
|
|
93
|
+
}),
|
|
94
|
+
}),
|
|
95
|
+
managedCachePolicy(simCfManagedCachePolicyIds.useOriginCacheControlHeaders, "UseOriginCacheControlHeaders", {
|
|
96
|
+
minTtlSec: 0,
|
|
97
|
+
defaultTtlSec: 0,
|
|
98
|
+
maxTtlSec: yearSeconds,
|
|
99
|
+
cacheKey: new SimCloudFrontCacheKey({
|
|
100
|
+
cookieBehavior: "all",
|
|
101
|
+
headerBehavior: "whitelist",
|
|
102
|
+
headers: originCacheControlHeaders,
|
|
103
|
+
enableAcceptEncodingGzip: true,
|
|
104
|
+
enableAcceptEncodingBrotli: true,
|
|
105
|
+
}),
|
|
106
|
+
}),
|
|
107
|
+
managedCachePolicy(simCfManagedCachePolicyIds.useOriginCacheControlHeadersQueryStrings, "UseOriginCacheControlHeaders-QueryStrings", {
|
|
108
|
+
minTtlSec: 0,
|
|
109
|
+
defaultTtlSec: 0,
|
|
110
|
+
maxTtlSec: yearSeconds,
|
|
111
|
+
cacheKey: new SimCloudFrontCacheKey({
|
|
112
|
+
cookieBehavior: "all",
|
|
113
|
+
headerBehavior: "whitelist",
|
|
114
|
+
headers: originCacheControlHeaders,
|
|
115
|
+
queryStringBehavior: "all",
|
|
116
|
+
enableAcceptEncodingGzip: true,
|
|
117
|
+
enableAcceptEncodingBrotli: true,
|
|
118
|
+
}),
|
|
119
|
+
}),
|
|
37
120
|
];
|
|
38
121
|
return new Map(policies.map((policy) => [policy.id, policy]));
|
|
39
122
|
}
|
|
40
123
|
/**
|
|
41
|
-
* One managed policy, under the ID and the
|
|
124
|
+
* One managed policy, under the ID, the name and the settings AWS gives it.
|
|
42
125
|
*/
|
|
43
|
-
function managedCachePolicy(id, name) {
|
|
126
|
+
function managedCachePolicy(id, name, settings) {
|
|
44
127
|
return new SimCloudFrontCachePolicy({
|
|
45
128
|
id: id,
|
|
46
129
|
name,
|
|
130
|
+
...settings,
|
|
47
131
|
});
|
|
48
132
|
}
|
|
@@ -2,6 +2,7 @@ import { assertNonNullable } from "@kensio/smartass";
|
|
|
2
2
|
import { SimAwsLocalUrl } from "../../../serve/http/url/sim-aws-local-url.js";
|
|
3
3
|
import { simHttpApiLambdaProxyFactory } from "../../apigatewayv2/api/sim-http-api-lambda-proxy.factory.js";
|
|
4
4
|
import { simCfDistroConfigFactory } from "../distribution/sim-cf-distro-config.factory.js";
|
|
5
|
+
import { simCfManagedOriginRequestPolicyIds } from "../origin-request-policy/sim-cf-managed-origin-request-policies.js";
|
|
5
6
|
import { makeCffFunctionCodeInput } from "./function-code-input/cff-function-code-input.js";
|
|
6
7
|
/**
|
|
7
8
|
* Put a viewer-request Function in front of an Origin echoing the query it is
|
|
@@ -36,6 +37,9 @@ export async function searchDistributionUrl(simAws, path, handler) {
|
|
|
36
37
|
DefaultCacheBehavior: {
|
|
37
38
|
TargetOriginId: "SiteOrigin",
|
|
38
39
|
ViewerProtocolPolicy: "allow-all",
|
|
40
|
+
// The Origin echoes the query it is sent, which reaches it only
|
|
41
|
+
// where the Behavior forwards it.
|
|
42
|
+
OriginRequestPolicyId: simCfManagedOriginRequestPolicyIds.allViewer,
|
|
39
43
|
FunctionAssociations: {
|
|
40
44
|
Items: [
|
|
41
45
|
{
|
|
@@ -4,14 +4,19 @@ import { SimCloudFrontCachePolicy } from "../../cache-policy/sim-cf-cache-policy
|
|
|
4
4
|
/**
|
|
5
5
|
* Reads an AWS::CloudFront::CachePolicy Resource into a simulated policy.
|
|
6
6
|
*
|
|
7
|
-
* `Name
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* The policy carries its `Name`, its `Comment`, its three TTLs and the cache
|
|
8
|
+
* key of its `ParametersInCacheKeyAndForwardedToOrigin`. A TTL a template left
|
|
9
|
+
* out falls back to CloudFront's own default rather than to nothing, so a
|
|
10
|
+
* policy holds what one in an account holds either way. A Resource missing its
|
|
11
|
+
* `Name` is refused, as CloudFormation refuses one.
|
|
11
12
|
*/
|
|
12
13
|
export declare class SimCfnCfCachePolicyConfig {
|
|
13
14
|
private readonly resource;
|
|
14
15
|
private readonly properties;
|
|
16
|
+
/**
|
|
17
|
+
* Refuse this Resource, saying which part of it could not be read.
|
|
18
|
+
*/
|
|
19
|
+
private readonly refuse;
|
|
15
20
|
constructor(properties: {
|
|
16
21
|
readonly resource: SimCfnResource;
|
|
17
22
|
readonly properties: SimCfnTemplateValueRecord;
|
|
@@ -20,8 +25,4 @@ export declare class SimCfnCfCachePolicyConfig {
|
|
|
20
25
|
* Build the simulated policy this Resource describes.
|
|
21
26
|
*/
|
|
22
27
|
build(): SimCloudFrontCachePolicy;
|
|
23
|
-
/**
|
|
24
|
-
* Refuse this Resource, saying which part of it could not be read.
|
|
25
|
-
*/
|
|
26
|
-
private refuse;
|
|
27
28
|
}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { isRecord } from "../../../../util/type-guard/record.js";
|
|
2
2
|
import { SimCloudFrontCachePolicy } from "../../cache-policy/sim-cf-cache-policy.js";
|
|
3
|
+
import { simCfnCfCachePolicyCacheKey } from "./sim-cfn-cf-cache-policy-key.js";
|
|
3
4
|
/**
|
|
4
5
|
* Reads an AWS::CloudFront::CachePolicy Resource into a simulated policy.
|
|
5
6
|
*
|
|
6
|
-
* `Name
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* The policy carries its `Name`, its `Comment`, its three TTLs and the cache
|
|
8
|
+
* key of its `ParametersInCacheKeyAndForwardedToOrigin`. A TTL a template left
|
|
9
|
+
* out falls back to CloudFront's own default rather than to nothing, so a
|
|
10
|
+
* policy holds what one in an account holds either way. A Resource missing its
|
|
11
|
+
* `Name` is refused, as CloudFormation refuses one.
|
|
10
12
|
*/
|
|
11
13
|
export class SimCfnCfCachePolicyConfig {
|
|
12
14
|
resource;
|
|
13
15
|
properties;
|
|
16
|
+
/**
|
|
17
|
+
* Refuse this Resource, saying which part of it could not be read.
|
|
18
|
+
*/
|
|
19
|
+
refuse = (detail) => {
|
|
20
|
+
throw new Error(`Invalid AWS::CloudFront::CachePolicy ${this.resource.logicalId}: ${detail}`);
|
|
21
|
+
};
|
|
14
22
|
constructor(properties) {
|
|
15
23
|
this.resource = properties.resource;
|
|
16
24
|
this.properties = properties.properties;
|
|
@@ -19,24 +27,45 @@ export class SimCfnCfCachePolicyConfig {
|
|
|
19
27
|
* Build the simulated policy this Resource describes.
|
|
20
28
|
*/
|
|
21
29
|
build() {
|
|
30
|
+
const { refuse } = this;
|
|
22
31
|
const config = this.properties["CachePolicyConfig"];
|
|
23
32
|
if (!isRecord(config)) {
|
|
24
|
-
return
|
|
33
|
+
return refuse("CachePolicyConfig must be an object");
|
|
25
34
|
}
|
|
26
35
|
const name = config["Name"];
|
|
27
36
|
if (typeof name !== "string") {
|
|
28
|
-
return
|
|
37
|
+
return refuse("CachePolicyConfig needs a string Name");
|
|
29
38
|
}
|
|
30
39
|
const comment = config["Comment"];
|
|
40
|
+
const minTtlSec = ttlSeconds(config, "MinTTL", refuse);
|
|
41
|
+
const defaultTtlSec = ttlSeconds(config, "DefaultTTL", refuse);
|
|
42
|
+
const maxTtlSec = ttlSeconds(config, "MaxTTL", refuse);
|
|
31
43
|
return new SimCloudFrontCachePolicy({
|
|
32
44
|
name,
|
|
33
45
|
...(typeof comment === "string" && { comment }),
|
|
46
|
+
...(minTtlSec !== undefined && { minTtlSec }),
|
|
47
|
+
...(defaultTtlSec !== undefined && { defaultTtlSec }),
|
|
48
|
+
...(maxTtlSec !== undefined && { maxTtlSec }),
|
|
49
|
+
cacheKey: simCfnCfCachePolicyCacheKey(config, refuse),
|
|
34
50
|
});
|
|
35
51
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* One TTL, or nothing where the template left it out for CloudFront's default
|
|
55
|
+
* to stand in.
|
|
56
|
+
*
|
|
57
|
+
* A template here is often a JavaScript object rather than parsed JSON, so a
|
|
58
|
+
* fraction, a negative or a NaN can reach this where a deployed template could
|
|
59
|
+
* not carry one, and none of them is a length of time an object could sit in a
|
|
60
|
+
* cache for.
|
|
61
|
+
*/
|
|
62
|
+
function ttlSeconds(config, field, refuse) {
|
|
63
|
+
// oxlint-disable-next-line security/detect-object-injection
|
|
64
|
+
const value = config[field];
|
|
65
|
+
if (value === undefined) {
|
|
66
|
+
return undefined;
|
|
41
67
|
}
|
|
68
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0
|
|
69
|
+
? value
|
|
70
|
+
: refuse(`CachePolicyConfig ${field} must be a whole number of seconds`);
|
|
42
71
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SimCloudFrontCacheKey } from "../../cache-policy/sim-cf-cache-key.js";
|
|
2
|
+
import { type SimCfnCfPolicyRefuse } from "../policy/sim-cfn-cf-policy-section.js";
|
|
3
|
+
/**
|
|
4
|
+
* Read the `ParametersInCacheKeyAndForwardedToOrigin` of a
|
|
5
|
+
* `CachePolicyConfig` into the cache key a policy carries.
|
|
6
|
+
*
|
|
7
|
+
* A template leaving the whole thing out gets CloudFront's own `none` in all
|
|
8
|
+
* three sections, with neither compression flag set.
|
|
9
|
+
*/
|
|
10
|
+
export declare function simCfnCfCachePolicyCacheKey(config: Record<string, unknown>, refuse: SimCfnCfPolicyRefuse): SimCloudFrontCacheKey;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isRecord } from "../../../../util/type-guard/record.js";
|
|
2
|
+
import { SimCloudFrontCacheKey } from "../../cache-policy/sim-cf-cache-key.js";
|
|
3
|
+
import { simCfnCfPolicySection, } from "../policy/sim-cfn-cf-policy-section.js";
|
|
4
|
+
import { simCfnCfCookiesSpec, simCfnCfHeadersSpec, simCfnCfQueryStringsSpec, } from "./sim-cfn-cf-cache-policy-section.js";
|
|
5
|
+
const parametersField = "ParametersInCacheKeyAndForwardedToOrigin";
|
|
6
|
+
/**
|
|
7
|
+
* Read the `ParametersInCacheKeyAndForwardedToOrigin` of a
|
|
8
|
+
* `CachePolicyConfig` into the cache key a policy carries.
|
|
9
|
+
*
|
|
10
|
+
* A template leaving the whole thing out gets CloudFront's own `none` in all
|
|
11
|
+
* three sections, with neither compression flag set.
|
|
12
|
+
*/
|
|
13
|
+
export function simCfnCfCachePolicyCacheKey(config, refuse) {
|
|
14
|
+
// oxlint-disable-next-line security/detect-object-injection
|
|
15
|
+
const parameters = config[parametersField];
|
|
16
|
+
if (parameters === undefined) {
|
|
17
|
+
return new SimCloudFrontCacheKey();
|
|
18
|
+
}
|
|
19
|
+
if (!isRecord(parameters)) {
|
|
20
|
+
return refuse(`${parametersField} must be an object`);
|
|
21
|
+
}
|
|
22
|
+
const cookies = simCfnCfPolicySection(parameters, simCfnCfCookiesSpec, refuse);
|
|
23
|
+
const headers = simCfnCfPolicySection(parameters, simCfnCfHeadersSpec, refuse);
|
|
24
|
+
const queries = simCfnCfPolicySection(parameters, simCfnCfQueryStringsSpec, refuse);
|
|
25
|
+
return new SimCloudFrontCacheKey({
|
|
26
|
+
cookieBehavior: cookies.behavior,
|
|
27
|
+
cookies: cookies.items,
|
|
28
|
+
headerBehavior: headers.behavior,
|
|
29
|
+
headers: headers.items,
|
|
30
|
+
queryStringBehavior: queries.behavior,
|
|
31
|
+
queryStrings: queries.items,
|
|
32
|
+
enableAcceptEncodingGzip: encodingFlag(parameters, "Gzip", refuse),
|
|
33
|
+
enableAcceptEncodingBrotli: encodingFlag(parameters, "Brotli", refuse),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* One of the two flags that put the normalized `Accept-Encoding` header in the
|
|
38
|
+
* cache key. Both are off where a template says nothing.
|
|
39
|
+
*/
|
|
40
|
+
function encodingFlag(parameters, encoding, refuse) {
|
|
41
|
+
const field = `EnableAcceptEncoding${encoding}`;
|
|
42
|
+
// oxlint-disable-next-line security/detect-object-injection
|
|
43
|
+
const value = parameters[field];
|
|
44
|
+
if (value === undefined) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return typeof value === "boolean"
|
|
48
|
+
? value
|
|
49
|
+
: refuse(`${parametersField} ${field} must be a boolean`);
|
|
50
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The three sections of a cache key, each with the fields CloudFormation
|
|
3
|
+
* names it by and the behaviours CloudFront offers for it.
|
|
4
|
+
*
|
|
5
|
+
* An origin request policy writes the same three sections under the same field
|
|
6
|
+
* names, and `simCfnCfPolicySection` reads either kind from a spec like these.
|
|
7
|
+
*/
|
|
8
|
+
export declare const simCfnCfCookiesSpec: {
|
|
9
|
+
readonly section: "CookiesConfig";
|
|
10
|
+
readonly behaviorField: "CookieBehavior";
|
|
11
|
+
readonly itemsField: "Cookies";
|
|
12
|
+
readonly behaviors: readonly ["none", "whitelist", "allExcept", "all"];
|
|
13
|
+
readonly defaultBehavior: "none";
|
|
14
|
+
};
|
|
15
|
+
export declare const simCfnCfHeadersSpec: {
|
|
16
|
+
readonly section: "HeadersConfig";
|
|
17
|
+
readonly behaviorField: "HeaderBehavior";
|
|
18
|
+
readonly itemsField: "Headers";
|
|
19
|
+
readonly behaviors: readonly ["none", "whitelist"];
|
|
20
|
+
readonly defaultBehavior: "none";
|
|
21
|
+
};
|
|
22
|
+
export declare const simCfnCfQueryStringsSpec: {
|
|
23
|
+
readonly section: "QueryStringsConfig";
|
|
24
|
+
readonly behaviorField: "QueryStringBehavior";
|
|
25
|
+
readonly itemsField: "QueryStrings";
|
|
26
|
+
readonly behaviors: readonly ["none", "whitelist", "allExcept", "all"];
|
|
27
|
+
readonly defaultBehavior: "none";
|
|
28
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { simCfCacheKeyCookieBehaviors, simCfCacheKeyHeaderBehaviors, simCfCacheKeyQueryStringBehaviors, } from "../../cache-policy/sim-cf-cache-key.js";
|
|
2
|
+
/**
|
|
3
|
+
* The three sections of a cache key, each with the fields CloudFormation
|
|
4
|
+
* names it by and the behaviours CloudFront offers for it.
|
|
5
|
+
*
|
|
6
|
+
* An origin request policy writes the same three sections under the same field
|
|
7
|
+
* names, and `simCfnCfPolicySection` reads either kind from a spec like these.
|
|
8
|
+
*/
|
|
9
|
+
export const simCfnCfCookiesSpec = {
|
|
10
|
+
section: "CookiesConfig",
|
|
11
|
+
behaviorField: "CookieBehavior",
|
|
12
|
+
itemsField: "Cookies",
|
|
13
|
+
behaviors: simCfCacheKeyCookieBehaviors,
|
|
14
|
+
defaultBehavior: "none",
|
|
15
|
+
};
|
|
16
|
+
export const simCfnCfHeadersSpec = {
|
|
17
|
+
section: "HeadersConfig",
|
|
18
|
+
behaviorField: "HeaderBehavior",
|
|
19
|
+
itemsField: "Headers",
|
|
20
|
+
behaviors: simCfCacheKeyHeaderBehaviors,
|
|
21
|
+
defaultBehavior: "none",
|
|
22
|
+
};
|
|
23
|
+
export const simCfnCfQueryStringsSpec = {
|
|
24
|
+
section: "QueryStringsConfig",
|
|
25
|
+
behaviorField: "QueryStringBehavior",
|
|
26
|
+
itemsField: "QueryStrings",
|
|
27
|
+
behaviors: simCfCacheKeyQueryStringBehaviors,
|
|
28
|
+
defaultBehavior: "none",
|
|
29
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SimCloudFront } from "../../sim-cloudfront.js";
|
|
2
|
+
/**
|
|
3
|
+
* One kind of policy a Behavior names, in the terms a template writes it in,
|
|
4
|
+
* with the way this simulation is asked whether it holds one and what the
|
|
5
|
+
* Behavior loses along with it.
|
|
6
|
+
*/
|
|
7
|
+
export interface BehaviorPolicyKind {
|
|
8
|
+
readonly property: "ResponseHeadersPolicyId" | "CachePolicyId" | "OriginRequestPolicyId";
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly loses: string;
|
|
11
|
+
readonly held: (cloudFront: SimCloudFront, policyId: string) => boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The three policies a Behavior names outside itself.
|
|
15
|
+
*/
|
|
16
|
+
export declare const behaviorPolicyKinds: readonly BehaviorPolicyKind[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The three policies a Behavior names outside itself.
|
|
3
|
+
*/
|
|
4
|
+
export const behaviorPolicyKinds = [
|
|
5
|
+
{
|
|
6
|
+
property: "ResponseHeadersPolicyId",
|
|
7
|
+
name: "response headers policy",
|
|
8
|
+
loses: "serves every response without the headers that policy would have set",
|
|
9
|
+
held: (cloudFront, policyId) => cloudFront.getResponseHeadersPolicyById(policyId) !== undefined,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
property: "CachePolicyId",
|
|
13
|
+
name: "cache policy",
|
|
14
|
+
loses: "reports no CachePolicyId",
|
|
15
|
+
held: (cloudFront, policyId) => cloudFront.getCachePolicyById(policyId) !== undefined,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
property: "OriginRequestPolicyId",
|
|
19
|
+
name: "origin request policy",
|
|
20
|
+
loses: "reports no OriginRequestPolicyId",
|
|
21
|
+
held: (cloudFront, policyId) => cloudFront.getOriginRequestPolicyById(policyId) !== undefined,
|
|
22
|
+
},
|
|
23
|
+
];
|
|
@@ -3,7 +3,8 @@ import type { SimCloudFrontDistributionConfig } from "../../command/create-distr
|
|
|
3
3
|
import type { SimCloudFront } from "../../sim-cloudfront.js";
|
|
4
4
|
/**
|
|
5
5
|
* The DistributionConfig to deploy, without a policy ID naming a response
|
|
6
|
-
* headers policy
|
|
6
|
+
* headers policy, a cache policy or an origin request policy this simulation
|
|
7
|
+
* does not hold.
|
|
7
8
|
*
|
|
8
9
|
* `CreateDistribution` refuses such an ID, as real CloudFront refuses one, and
|
|
9
10
|
* a Distribution deployed from a template is the one place that refusal costs
|
|
@@ -19,6 +20,6 @@ import type { SimCloudFront } from "../../sim-cloudfront.js";
|
|
|
19
20
|
* naming one keeps it.
|
|
20
21
|
*
|
|
21
22
|
* One Behavior losing a policy leaves the others holding theirs, and a
|
|
22
|
-
* Behavior losing one kind of policy keeps the
|
|
23
|
+
* Behavior losing one kind of policy keeps the others.
|
|
23
24
|
*/
|
|
24
25
|
export declare function simCfnCfDistroWithHeldBehaviorPolicies(resource: SimCfnResource, distributionConfig: SimCloudFrontDistributionConfig, cloudFront: SimCloudFront): SimCloudFrontDistributionConfig;
|
|
@@ -6,7 +6,8 @@ import { SimCfnCfDistroPolicyDrops } from "./sim-cfn-cf-distro-policy-drops.js";
|
|
|
6
6
|
const defaultBehaviorPath = "DistributionConfig.DefaultCacheBehavior";
|
|
7
7
|
/**
|
|
8
8
|
* The DistributionConfig to deploy, without a policy ID naming a response
|
|
9
|
-
* headers policy
|
|
9
|
+
* headers policy, a cache policy or an origin request policy this simulation
|
|
10
|
+
* does not hold.
|
|
10
11
|
*
|
|
11
12
|
* `CreateDistribution` refuses such an ID, as real CloudFront refuses one, and
|
|
12
13
|
* a Distribution deployed from a template is the one place that refusal costs
|
|
@@ -22,7 +23,7 @@ const defaultBehaviorPath = "DistributionConfig.DefaultCacheBehavior";
|
|
|
22
23
|
* naming one keeps it.
|
|
23
24
|
*
|
|
24
25
|
* One Behavior losing a policy leaves the others holding theirs, and a
|
|
25
|
-
* Behavior losing one kind of policy keeps the
|
|
26
|
+
* Behavior losing one kind of policy keeps the others.
|
|
26
27
|
*/
|
|
27
28
|
export function simCfnCfDistroWithHeldBehaviorPolicies(resource, distributionConfig, cloudFront) {
|
|
28
29
|
const drops = new SimCfnCfDistroPolicyDrops(resource, cloudFront);
|
|
@@ -10,12 +10,12 @@ interface SimCfnCfDistroCreatorProperties {
|
|
|
10
10
|
*
|
|
11
11
|
* A `WebACLId` naming a web ACL this simulation does not hold is left out and
|
|
12
12
|
* recorded, and so are a Lambda@Edge association it cannot run and a
|
|
13
|
-
* `ResponseHeadersPolicyId` or `
|
|
14
|
-
* hold. CloudFront has no Resource of its own for
|
|
15
|
-
* live on the Distribution itself, and refusing
|
|
16
|
-
* Distribution down over something that was never the point
|
|
17
|
-
* The site a local dev server and a suite of tests make
|
|
18
|
-
* survive that.
|
|
13
|
+
* `ResponseHeadersPolicyId`, `CachePolicyId` or `OriginRequestPolicyId`
|
|
14
|
+
* naming a policy it does not hold. CloudFront has no Resource of its own for
|
|
15
|
+
* any of them, so all of them live on the Distribution itself, and refusing
|
|
16
|
+
* one would take the Distribution down over something that was never the point
|
|
17
|
+
* of the template. The site a local dev server and a suite of tests make
|
|
18
|
+
* requests to has to survive that.
|
|
19
19
|
*/
|
|
20
20
|
export declare class SimCfnCfDistroCreator {
|
|
21
21
|
private readonly cloudFront;
|
|
@@ -9,12 +9,12 @@ import { simCfnResourceCallerOptions } from "../../../cloudformation/resource/ca
|
|
|
9
9
|
*
|
|
10
10
|
* A `WebACLId` naming a web ACL this simulation does not hold is left out and
|
|
11
11
|
* recorded, and so are a Lambda@Edge association it cannot run and a
|
|
12
|
-
* `ResponseHeadersPolicyId` or `
|
|
13
|
-
* hold. CloudFront has no Resource of its own for
|
|
14
|
-
* live on the Distribution itself, and refusing
|
|
15
|
-
* Distribution down over something that was never the point
|
|
16
|
-
* The site a local dev server and a suite of tests make
|
|
17
|
-
* survive that.
|
|
12
|
+
* `ResponseHeadersPolicyId`, `CachePolicyId` or `OriginRequestPolicyId`
|
|
13
|
+
* naming a policy it does not hold. CloudFront has no Resource of its own for
|
|
14
|
+
* any of them, so all of them live on the Distribution itself, and refusing
|
|
15
|
+
* one would take the Distribution down over something that was never the point
|
|
16
|
+
* of the template. The site a local dev server and a suite of tests make
|
|
17
|
+
* requests to has to survive that.
|
|
18
18
|
*/
|
|
19
19
|
export class SimCfnCfDistroCreator {
|
|
20
20
|
cloudFront;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { behaviorPolicyKinds, } from "./sim-cfn-cf-behavior-policy-kinds.js";
|
|
1
2
|
/**
|
|
2
3
|
* Takes a policy ID naming a policy this simulation does not hold off the
|
|
3
4
|
* Behavior that named it, and records each one on the Resource.
|
|
@@ -15,36 +16,20 @@ export class SimCfnCfDistroPolicyDrops {
|
|
|
15
16
|
* are not.
|
|
16
17
|
*/
|
|
17
18
|
heldPolicies(behavior, behaviorPath) {
|
|
18
|
-
|
|
19
|
-
return this.heldPolicy(withHeaders, behaviorPath, "CachePolicyId", (policyId) => this.cloudFront.getCachePolicyById(policyId) !== undefined, cachePolicyDropReason);
|
|
19
|
+
return behaviorPolicyKinds.reduce((held, kind) => this.heldPolicy(held, behaviorPath, kind), behavior);
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* One policy property of one Behavior, dropped where the ID names nothing
|
|
23
23
|
* this simulation holds.
|
|
24
24
|
*/
|
|
25
|
-
heldPolicy(behavior, behaviorPath,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (policyId === undefined || held(policyId)) {
|
|
25
|
+
heldPolicy(behavior, behaviorPath, kind) {
|
|
26
|
+
const policyId = behavior[kind.property];
|
|
27
|
+
if (policyId === undefined || kind.held(this.cloudFront, policyId)) {
|
|
29
28
|
return behavior;
|
|
30
29
|
}
|
|
31
30
|
this.count += 1;
|
|
32
|
-
this.resource.ignoreProperty(`${behaviorPath}.${property}`,
|
|
33
|
-
|
|
31
|
+
this.resource.ignoreProperty(`${behaviorPath}.${kind.property}`, `${kind.name} ${policyId} is not held by this simulation, so the ` +
|
|
32
|
+
`Behavior is deployed without one and ${kind.loses}`);
|
|
33
|
+
return { ...behavior, [kind.property]: undefined };
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
/**
|
|
37
|
-
* What a Behavior loses along with a response headers policy.
|
|
38
|
-
*/
|
|
39
|
-
function headersPolicyDropReason(policyId) {
|
|
40
|
-
return (`response headers policy ${policyId} is not held by this simulation, so ` +
|
|
41
|
-
`the Behavior is deployed without one and serves every response without ` +
|
|
42
|
-
`the headers that policy would have set`);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* What a Behavior loses along with a cache policy.
|
|
46
|
-
*/
|
|
47
|
-
function cachePolicyDropReason(policyId) {
|
|
48
|
-
return (`cache policy ${policyId} is not held by this simulation, so the ` +
|
|
49
|
-
`Behavior is deployed without one and reports no CachePolicyId`);
|
|
50
|
-
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { SimCfnResource } from "../../../cloudformation/resource/sim-cfn-resource.js";
|
|
2
|
+
import type { SimCfnTemplateValueRecord } from "../../../cloudformation/template/value/sim-cfn-template-value.js";
|
|
3
|
+
import { SimCloudFrontOriginRequestPolicy } from "../../origin-request-policy/sim-cf-origin-request-policy.js";
|
|
4
|
+
/**
|
|
5
|
+
* Reads an AWS::CloudFront::OriginRequestPolicy Resource into a simulated
|
|
6
|
+
* policy.
|
|
7
|
+
*
|
|
8
|
+
* The policy carries its `Name`, its `Comment` and the three sections that say
|
|
9
|
+
* what it forwards to the Origin. A section a template left out falls back to
|
|
10
|
+
* CloudFront's `none`. A Resource missing its `Name` is refused, as
|
|
11
|
+
* CloudFormation refuses one.
|
|
12
|
+
*/
|
|
13
|
+
export declare class SimCfnCfOriginRequestPolicyConfig {
|
|
14
|
+
private readonly resource;
|
|
15
|
+
private readonly properties;
|
|
16
|
+
/**
|
|
17
|
+
* Refuse this Resource, saying which part of it could not be read.
|
|
18
|
+
*/
|
|
19
|
+
private readonly refuse;
|
|
20
|
+
constructor(properties: {
|
|
21
|
+
readonly resource: SimCfnResource;
|
|
22
|
+
readonly properties: SimCfnTemplateValueRecord;
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Build the simulated policy this Resource describes.
|
|
26
|
+
*/
|
|
27
|
+
build(): SimCloudFrontOriginRequestPolicy;
|
|
28
|
+
}
|