@composurecdk/cloudfront 0.6.0 → 0.8.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/commonjs/alarm-config.d.ts.map +1 -0
- package/dist/commonjs/alarm-config.js +3 -0
- package/dist/{alarm-config.js.map → commonjs/alarm-config.js.map} +1 -1
- package/dist/commonjs/alarm-defaults.d.ts.map +1 -0
- package/dist/commonjs/alarm-defaults.js +65 -0
- package/dist/commonjs/alarm-defaults.js.map +1 -0
- package/dist/commonjs/behavior-function-alarms.d.ts.map +1 -0
- package/dist/commonjs/behavior-function-alarms.js +145 -0
- package/dist/commonjs/behavior-function-alarms.js.map +1 -0
- package/dist/{cloudfront-alarm-builder.d.ts → commonjs/cloudfront-alarm-builder.d.ts} +5 -2
- package/dist/commonjs/cloudfront-alarm-builder.d.ts.map +1 -0
- package/dist/commonjs/cloudfront-alarm-builder.js +141 -0
- package/dist/commonjs/cloudfront-alarm-builder.js.map +1 -0
- package/dist/commonjs/defaults.d.ts.map +1 -0
- package/dist/commonjs/defaults.js +72 -0
- package/dist/commonjs/defaults.js.map +1 -0
- package/dist/commonjs/distribution-alarms.d.ts.map +1 -0
- package/dist/commonjs/distribution-alarms.js +64 -0
- package/dist/commonjs/distribution-alarms.js.map +1 -0
- package/dist/{distribution-builder.d.ts → commonjs/distribution-builder.d.ts} +5 -2
- package/dist/commonjs/distribution-builder.d.ts.map +1 -0
- package/dist/commonjs/distribution-builder.js +191 -0
- package/dist/commonjs/distribution-builder.js.map +1 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +14 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/resolve-behaviors.d.ts.map +1 -0
- package/dist/commonjs/resolve-behaviors.js +101 -0
- package/dist/commonjs/resolve-behaviors.js.map +1 -0
- package/dist/esm/alarm-config.d.ts +98 -0
- package/dist/esm/alarm-config.d.ts.map +1 -0
- package/dist/esm/alarm-config.js.map +1 -0
- package/dist/esm/alarm-defaults.d.ts +28 -0
- package/dist/esm/alarm-defaults.d.ts.map +1 -0
- package/dist/esm/alarm-defaults.js.map +1 -0
- package/dist/esm/behavior-function-alarms.d.ts +44 -0
- package/dist/esm/behavior-function-alarms.d.ts.map +1 -0
- package/dist/esm/behavior-function-alarms.js.map +1 -0
- package/dist/esm/cloudfront-alarm-builder.d.ts +136 -0
- package/dist/esm/cloudfront-alarm-builder.d.ts.map +1 -0
- package/dist/{cloudfront-alarm-builder.js → esm/cloudfront-alarm-builder.js} +8 -2
- package/dist/esm/cloudfront-alarm-builder.js.map +1 -0
- package/dist/esm/defaults.d.ts +17 -0
- package/dist/esm/defaults.d.ts.map +1 -0
- package/dist/esm/defaults.js.map +1 -0
- package/dist/esm/distribution-alarms.d.ts +9 -0
- package/dist/esm/distribution-alarms.d.ts.map +1 -0
- package/dist/esm/distribution-alarms.js.map +1 -0
- package/dist/esm/distribution-builder.d.ts +345 -0
- package/dist/esm/distribution-builder.d.ts.map +1 -0
- package/dist/{distribution-builder.js → esm/distribution-builder.js} +12 -2
- package/dist/esm/distribution-builder.js.map +1 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/resolve-behaviors.d.ts +56 -0
- package/dist/esm/resolve-behaviors.d.ts.map +1 -0
- package/dist/esm/resolve-behaviors.js.map +1 -0
- package/package.json +36 -17
- package/dist/alarm-config.d.ts.map +0 -1
- package/dist/alarm-defaults.d.ts.map +0 -1
- package/dist/alarm-defaults.js.map +0 -1
- package/dist/behavior-function-alarms.d.ts.map +0 -1
- package/dist/behavior-function-alarms.js.map +0 -1
- package/dist/cloudfront-alarm-builder.d.ts.map +0 -1
- package/dist/cloudfront-alarm-builder.js.map +0 -1
- package/dist/defaults.d.ts.map +0 -1
- package/dist/defaults.js.map +0 -1
- package/dist/distribution-alarms.d.ts.map +0 -1
- package/dist/distribution-alarms.js.map +0 -1
- package/dist/distribution-builder.d.ts.map +0 -1
- package/dist/distribution-builder.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/resolve-behaviors.d.ts.map +0 -1
- package/dist/resolve-behaviors.js.map +0 -1
- /package/dist/{alarm-config.d.ts → commonjs/alarm-config.d.ts} +0 -0
- /package/dist/{alarm-defaults.d.ts → commonjs/alarm-defaults.d.ts} +0 -0
- /package/dist/{behavior-function-alarms.d.ts → commonjs/behavior-function-alarms.d.ts} +0 -0
- /package/dist/{defaults.d.ts → commonjs/defaults.d.ts} +0 -0
- /package/dist/{distribution-alarms.d.ts → commonjs/distribution-alarms.d.ts} +0 -0
- /package/dist/{index.d.ts → commonjs/index.d.ts} +0 -0
- /package/dist/{resolve-behaviors.d.ts → commonjs/resolve-behaviors.d.ts} +0 -0
- /package/dist/{alarm-config.js → esm/alarm-config.js} +0 -0
- /package/dist/{alarm-defaults.js → esm/alarm-defaults.js} +0 -0
- /package/dist/{behavior-function-alarms.js → esm/behavior-function-alarms.js} +0 -0
- /package/dist/{defaults.js → esm/defaults.js} +0 -0
- /package/dist/{distribution-alarms.js → esm/distribution-alarms.js} +0 -0
- /package/dist/{index.js → esm/index.js} +0 -0
- /package/dist/{resolve-behaviors.js → esm/resolve-behaviors.js} +0 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { type Distribution } from "aws-cdk-lib/aws-cloudfront";
|
|
2
|
+
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
3
|
+
import { type IConstruct } from "constructs";
|
|
4
|
+
import { COPY_STATE, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
5
|
+
import { type ITaggedBuilder } from "@composurecdk/cloudformation";
|
|
6
|
+
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
7
|
+
import type { DistributionAlarmConfig } from "./alarm-config.js";
|
|
8
|
+
import type { DistributionBuilderResult } from "./distribution-builder.js";
|
|
9
|
+
/**
|
|
10
|
+
* Configuration properties for {@link createCloudFrontAlarmBuilder}.
|
|
11
|
+
*
|
|
12
|
+
* The standalone alarm builder mirrors the alarm surface that
|
|
13
|
+
* {@link createDistributionBuilder} creates by default. It exists so that
|
|
14
|
+
* alarms can be created in a different stack from the distribution itself —
|
|
15
|
+
* specifically a `us-east-1` stack, since CloudFront emits all metrics there
|
|
16
|
+
* regardless of the distribution's stack region.
|
|
17
|
+
*/
|
|
18
|
+
export interface CloudFrontAlarmBuilderProps {
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for AWS-recommended CloudWatch alarms — distribution-level
|
|
21
|
+
* (5xx error rate, origin latency) and per-function (execution errors,
|
|
22
|
+
* validation errors, throttles).
|
|
23
|
+
*
|
|
24
|
+
* Mirrors {@link DistributionBuilderProps.recommendedAlarms}. Set to
|
|
25
|
+
* `false` to disable all recommended alarms; per-function alarms further
|
|
26
|
+
* respect each function's own {@link InlineFunctionDefinition.recommendedAlarms}
|
|
27
|
+
* value. Custom alarms added via {@link ICloudFrontAlarmBuilder.addAlarm}
|
|
28
|
+
* are unaffected.
|
|
29
|
+
*
|
|
30
|
+
* No alarm actions are configured by default. Use `alarmActionsPolicy` (or
|
|
31
|
+
* an `afterBuild` hook) to wire SNS or other actions onto the resulting
|
|
32
|
+
* alarms.
|
|
33
|
+
*
|
|
34
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#CloudFront
|
|
35
|
+
*/
|
|
36
|
+
recommendedAlarms?: DistributionAlarmConfig | false;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The build output of an {@link ICloudFrontAlarmBuilder}.
|
|
40
|
+
*/
|
|
41
|
+
export interface CloudFrontAlarmBuilderResult {
|
|
42
|
+
/**
|
|
43
|
+
* The CloudWatch alarms created by this builder, keyed by alarm name. Uses
|
|
44
|
+
* the same key scheme as {@link DistributionBuilderResult.alarms}.
|
|
45
|
+
*/
|
|
46
|
+
alarms: Record<string, Alarm>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A fluent builder for CloudFront-related CloudWatch alarms, decoupled from
|
|
50
|
+
* the distribution itself. Use this when the distribution lives in a stack
|
|
51
|
+
* outside `us-east-1` — route this builder's component into a us-east-1
|
|
52
|
+
* stack via `compose().withStacks()` so the alarms land where CloudFront
|
|
53
|
+
* actually emits metrics.
|
|
54
|
+
*
|
|
55
|
+
* @see {@link createCloudFrontAlarmBuilder}
|
|
56
|
+
*/
|
|
57
|
+
export type ICloudFrontAlarmBuilder = ITaggedBuilder<CloudFrontAlarmBuilderProps, CloudFrontAlarmBuilder>;
|
|
58
|
+
/**
|
|
59
|
+
* Shared alarm-assembly used by both {@link createDistributionBuilder} (in its
|
|
60
|
+
* own stack) and {@link createCloudFrontAlarmBuilder} (typically in a separate
|
|
61
|
+
* `us-east-1` stack). Materializes the recommended distribution-level alarms,
|
|
62
|
+
* the recommended per-function alarms, and any user-supplied custom alarms,
|
|
63
|
+
* emits the region warning if the resulting scope is not in `us-east-1`, and
|
|
64
|
+
* creates the alarm constructs.
|
|
65
|
+
*
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
export declare function buildCloudFrontAlarms(scope: IConstruct, id: string, target: Pick<DistributionBuilderResult, "distribution" | "functions">, options?: {
|
|
69
|
+
recommendedAlarms?: DistributionAlarmConfig | false;
|
|
70
|
+
customAlarms?: AlarmDefinitionBuilder<Distribution>[];
|
|
71
|
+
}): Record<string, Alarm>;
|
|
72
|
+
declare class CloudFrontAlarmBuilder implements Lifecycle<CloudFrontAlarmBuilderResult> {
|
|
73
|
+
#private;
|
|
74
|
+
props: Partial<CloudFrontAlarmBuilderProps>;
|
|
75
|
+
/**
|
|
76
|
+
* Sets the distribution to alarm on. Pass the result of
|
|
77
|
+
* {@link createDistributionBuilder} (or a {@link Ref} to it). The builder
|
|
78
|
+
* reads the distribution and any inline-function metadata from the result.
|
|
79
|
+
*
|
|
80
|
+
* Pair with `compose().withStacks()` to route this component into a
|
|
81
|
+
* `us-east-1` stack while the distribution itself lives elsewhere — set
|
|
82
|
+
* `crossRegionReferences: true` on both stacks so CDK can wire the
|
|
83
|
+
* `DistributionId` reference automatically.
|
|
84
|
+
*/
|
|
85
|
+
distribution(distribution: Resolvable<DistributionBuilderResult>): this;
|
|
86
|
+
/**
|
|
87
|
+
* Adds a custom alarm against the distribution. The configure callback
|
|
88
|
+
* receives a fresh {@link AlarmDefinitionBuilder} pre-set with the alarm's
|
|
89
|
+
* key; configure metric, threshold, comparison and any other options.
|
|
90
|
+
*
|
|
91
|
+
* The created alarm is materialized in this builder's stack — useful for
|
|
92
|
+
* cross-region setups where you want all CloudFront alarms to live with the
|
|
93
|
+
* recommended ones.
|
|
94
|
+
*/
|
|
95
|
+
addAlarm(key: string, configure: (alarm: AlarmDefinitionBuilder<Distribution>) => AlarmDefinitionBuilder<Distribution>): this;
|
|
96
|
+
/** @internal — see ADR-0005. */
|
|
97
|
+
[COPY_STATE](target: CloudFrontAlarmBuilder): void;
|
|
98
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): CloudFrontAlarmBuilderResult;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Creates a new {@link ICloudFrontAlarmBuilder} for materializing CloudFront
|
|
102
|
+
* alarms in a stack separate from the distribution itself.
|
|
103
|
+
*
|
|
104
|
+
* The recommended use is multi-region deployments: the distribution lives in
|
|
105
|
+
* the site's stack (often outside `us-east-1` for latency or compliance
|
|
106
|
+
* reasons), and CloudFront alarms must live in a `us-east-1` stack so they
|
|
107
|
+
* can read the metrics CloudFront emits there.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* compose(
|
|
112
|
+
* {
|
|
113
|
+
* cdn: createDistributionBuilder()
|
|
114
|
+
* .origin(...)
|
|
115
|
+
* .defaultBehavior({ functions: [{ eventType, code }] })
|
|
116
|
+
* .recommendedAlarms(false), // suppress alarms in the dist's own stack
|
|
117
|
+
*
|
|
118
|
+
* cdnAlarms: createCloudFrontAlarmBuilder()
|
|
119
|
+
* .distribution(ref<DistributionBuilderResult>("cdn"))
|
|
120
|
+
* .recommendedAlarms({ errorRate: { threshold: 2 } }),
|
|
121
|
+
* },
|
|
122
|
+
* { cdn: [], cdnAlarms: ["cdn"] },
|
|
123
|
+
* )
|
|
124
|
+
* .withStacks({
|
|
125
|
+
* cdn: siteStack, // eu-west-2
|
|
126
|
+
* cdnAlarms: certStack, // us-east-1 (existing ACM stack)
|
|
127
|
+
* })
|
|
128
|
+
* .build(app, "App");
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* Set `crossRegionReferences: true` on both stacks so CDK can export the
|
|
132
|
+
* `DistributionId` from the site stack and import it in the alarm stack.
|
|
133
|
+
*/
|
|
134
|
+
export declare function createCloudFrontAlarmBuilder(): ICloudFrontAlarmBuilder;
|
|
135
|
+
export {};
|
|
136
|
+
//# sourceMappingURL=cloudfront-alarm-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudfront-alarm-builder.d.ts","sourceRoot":"","sources":["../../src/cloudfront-alarm-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAW,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,8BAA8B,CAAC;AAElF,OAAO,EAAE,sBAAsB,EAAgB,MAAM,0BAA0B,CAAC;AAChF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAGjE,OAAO,KAAK,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M,EACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,4BAA4B;CAehC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,4BAA4B,IAAI,uBAAuB,CAEtE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Annotations, Stack, Token } from "aws-cdk-lib";
|
|
2
|
-
import {
|
|
2
|
+
import { COPY_STATE, resolve } from "@composurecdk/core";
|
|
3
|
+
import { taggedBuilder } from "@composurecdk/cloudformation";
|
|
3
4
|
import { AlarmDefinitionBuilder, createAlarms } from "@composurecdk/cloudwatch";
|
|
4
5
|
import { resolveDistributionAlarmDefinitions } from "./distribution-alarms.js";
|
|
5
6
|
import { resolveBehaviorFunctionAlarmDefinitions } from "./behavior-function-alarms.js";
|
|
@@ -77,6 +78,11 @@ class CloudFrontAlarmBuilder {
|
|
|
77
78
|
this.#customAlarms.push(configure(new AlarmDefinitionBuilder(key)));
|
|
78
79
|
return this;
|
|
79
80
|
}
|
|
81
|
+
/** @internal — see ADR-0005. */
|
|
82
|
+
[COPY_STATE](target) {
|
|
83
|
+
target.#distribution = this.#distribution;
|
|
84
|
+
target.#customAlarms.push(...this.#customAlarms);
|
|
85
|
+
}
|
|
80
86
|
build(scope, id, context) {
|
|
81
87
|
if (!this.#distribution) {
|
|
82
88
|
throw new Error(`CloudFrontAlarmBuilder "${id}" requires a distribution. ` +
|
|
@@ -126,6 +132,6 @@ class CloudFrontAlarmBuilder {
|
|
|
126
132
|
* `DistributionId` from the site stack and import it in the alarm stack.
|
|
127
133
|
*/
|
|
128
134
|
export function createCloudFrontAlarmBuilder() {
|
|
129
|
-
return
|
|
135
|
+
return taggedBuilder(CloudFrontAlarmBuilder);
|
|
130
136
|
}
|
|
131
137
|
//# sourceMappingURL=cloudfront-alarm-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudfront-alarm-builder.js","sourceR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C;QAEhC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CACb,2BAA2B,EAAE,6BAA6B;gBACxD,wEAAwE,CAC3E,CAAC;QACJ,CAAC;QACD,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;QAChE,OAAO;YACL,MAAM,EAAE,qBAAqB,CAAC,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE;gBACrD,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,iBAAiB;gBAC/C,YAAY,EAAE,IAAI,CAAC,aAAa;aACjC,CAAC;SACH,CAAC;IACJ,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,4BAA4B;IAC1C,OAAO,aAAa,CAAsD,sBAAsB,CAAC,CAAC;AACpG,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DistributionBuilderProps, InlineFunctionDefinition } from "./distribution-builder.js";
|
|
2
|
+
/**
|
|
3
|
+
* Secure, AWS-recommended defaults applied to every CloudFront distribution
|
|
4
|
+
* built with {@link createDistributionBuilder}. Each property can be individually
|
|
5
|
+
* overridden via the builder's fluent API.
|
|
6
|
+
*
|
|
7
|
+
* The `defaultBehavior` defaults (viewer protocol policy, response headers
|
|
8
|
+
* policy) are deep-merged with user-provided behavior options in `build()`,
|
|
9
|
+
* then the resolved origin is injected.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DISTRIBUTION_DEFAULTS: Partial<DistributionBuilderProps>;
|
|
12
|
+
/**
|
|
13
|
+
* Defaults applied to every inline CloudFront Function declared on a cache
|
|
14
|
+
* behavior. User-provided properties take precedence.
|
|
15
|
+
*/
|
|
16
|
+
export declare const INLINE_FUNCTION_DEFAULTS: Partial<InlineFunctionDefinition>;
|
|
17
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAEpG;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,OAAO,CAAC,wBAAwB,CAmDnE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,OAAO,CAAC,wBAAwB,CAOtE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,WAAW,EACX,UAAU,EACV,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AAGpC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAsC;IACtE;;;;;;OAMG;IACH,UAAU,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;IAE/B;;;;OAIG;IACH,UAAU,EAAE,UAAU,CAAC,eAAe;IAEtC;;;;OAIG;IACH,WAAW,EAAE,WAAW,CAAC,WAAW;IAEpC;;;OAGG;IACH,iBAAiB,EAAE,YAAY;IAE/B;;;;OAIG;IACH,sBAAsB,EAAE,sBAAsB,CAAC,aAAa;IAE5D,eAAe,EAAE;QACf;;;WAGG;QACH,oBAAoB,EAAE,oBAAoB,CAAC,iBAAiB;QAE5D;;;;WAIG;QACH,qBAAqB,EAAE,qBAAqB,CAAC,gBAAgB;KAC9D;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAsC;IACzE;;;;OAIG;IACH,OAAO,EAAE,eAAe,CAAC,MAAM;CAChC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Distribution } from "aws-cdk-lib/aws-cloudfront";
|
|
2
|
+
import type { AlarmDefinition } from "@composurecdk/cloudwatch";
|
|
3
|
+
import type { DistributionAlarmConfig } from "./alarm-config.js";
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the recommended alarm configuration into fully-resolved
|
|
6
|
+
* {@link AlarmDefinition}s for a CloudFront distribution.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveDistributionAlarmDefinitions(distribution: Distribution, config: DistributionAlarmConfig | undefined): AlarmDefinition[];
|
|
9
|
+
//# sourceMappingURL=distribution-alarms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distribution-alarms.d.ts","sourceRoot":"","sources":["../../src/distribution-alarms.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AA2BjE;;;GAGG;AACH,wBAAgB,mCAAmC,CACjD,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,uBAAuB,GAAG,SAAS,GAC1C,eAAe,EAAE,CAuCnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distribution-alarms.js","sourceRoot":"","sources":["../../src/distribution-alarms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAG/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAElE,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1C,MAAM,mBAAmB,GAAG,GAAG,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC;AAE1E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,CAC1C,CAAC;QACF,WAAW,CAAC,IAAI,CAAC;YACf,GAAG,EAAE,eAAe;YACpB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,MAAM,EAAE,kBAAkB,CAAC,YAAY,EAAE,eAAe,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YAC/E,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,kBAAkB,EAAE,kBAAkB,CAAC,sBAAsB;YAC7D,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;YACxC,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;YACxC,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;YACtC,WAAW,EAAE,uDAAuD,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,aAAa,mBAAmB,GAAG;SAC7H,CAAC,CAAC;IACL,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { Distribution, type DistributionProps, type IOrigin, type AddBehaviorOptions, type BehaviorOptions, type Function as CfFunction, type FunctionCode, type FunctionEventType, type FunctionRuntime, type IKeyValueStore } from "aws-cdk-lib/aws-cloudfront";
|
|
2
|
+
import { type ICertificate } from "aws-cdk-lib/aws-certificatemanager";
|
|
3
|
+
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
4
|
+
import { type Bucket, type IBucket } from "aws-cdk-lib/aws-s3";
|
|
5
|
+
import { type IConstruct } from "constructs";
|
|
6
|
+
import { COPY_STATE, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
7
|
+
import { type ITaggedBuilder } from "@composurecdk/cloudformation";
|
|
8
|
+
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
9
|
+
import { type IBucketBuilder } from "@composurecdk/s3";
|
|
10
|
+
import type { DistributionAlarmConfig, FunctionAlarmConfig } from "./alarm-config.js";
|
|
11
|
+
/**
|
|
12
|
+
* Per-function metadata exposed on {@link DistributionBuilderResult.functions}.
|
|
13
|
+
* Bundles the CDK construct with the behavior context the builder used to
|
|
14
|
+
* create it. Consumers (notably {@link createCloudFrontAlarmBuilder}) use the
|
|
15
|
+
* `pathPattern`, `eventType`, and `recommendedAlarms` fields to reproduce the
|
|
16
|
+
* same recommended alarms in a different stack.
|
|
17
|
+
*/
|
|
18
|
+
export interface FunctionEntry {
|
|
19
|
+
/** The CloudFront Function created by the distribution builder. */
|
|
20
|
+
function: CfFunction;
|
|
21
|
+
/**
|
|
22
|
+
* The behavior the function is attached to. `null` for the default behavior;
|
|
23
|
+
* otherwise the path pattern (e.g. `"/api/*"`).
|
|
24
|
+
*/
|
|
25
|
+
pathPattern: string | null;
|
|
26
|
+
/** The viewer event the function handles. */
|
|
27
|
+
eventType: FunctionEventType;
|
|
28
|
+
/**
|
|
29
|
+
* The {@link InlineFunctionDefinition.recommendedAlarms} value the user
|
|
30
|
+
* supplied for this function. Omitted entirely when the user did not
|
|
31
|
+
* provide one — consumers should treat that as "use defaults".
|
|
32
|
+
*/
|
|
33
|
+
recommendedAlarms?: FunctionAlarmConfig | false;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A CloudFront Function declared inline on a cache behavior. The distribution
|
|
37
|
+
* builder creates the underlying {@link CfFunction} construct and wires it
|
|
38
|
+
* into the behavior's function associations. Recommended alarms for the
|
|
39
|
+
* function are emitted automatically, scoped to the behavior's path pattern.
|
|
40
|
+
*
|
|
41
|
+
* Only inline declarations are supported — there is no "bring your own
|
|
42
|
+
* function" escape hatch, because the whole point of owning the function is
|
|
43
|
+
* to emit path-scoped `FunctionExecutionErrors` / `FunctionValidationErrors`
|
|
44
|
+
* / `FunctionThrottles` alarms that couldn't be emitted from an external
|
|
45
|
+
* `IFunctionRef` (which exposes only an ARN, not a function name).
|
|
46
|
+
*
|
|
47
|
+
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-functions.html
|
|
48
|
+
*/
|
|
49
|
+
export interface InlineFunctionDefinition {
|
|
50
|
+
/** The viewer event that should invoke the function. */
|
|
51
|
+
eventType: FunctionEventType;
|
|
52
|
+
/** The source for the function — `FunctionCode.fromInline()` or `.fromFile()`. */
|
|
53
|
+
code: FunctionCode;
|
|
54
|
+
/**
|
|
55
|
+
* Explicit physical name for the function. Useful when operators search
|
|
56
|
+
* CloudWatch logs or metrics by function name rather than by ARN. If omitted,
|
|
57
|
+
* CDK generates a name derived from the construct path.
|
|
58
|
+
*/
|
|
59
|
+
functionName?: string;
|
|
60
|
+
/**
|
|
61
|
+
* JavaScript runtime.
|
|
62
|
+
* @default FunctionRuntime.JS_2_0
|
|
63
|
+
*/
|
|
64
|
+
runtime?: FunctionRuntime;
|
|
65
|
+
/** Optional comment stored on the function resource. */
|
|
66
|
+
comment?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Key-value store to associate with the function. Only supported on the
|
|
69
|
+
* `cloudfront-js-2.0` runtime.
|
|
70
|
+
*/
|
|
71
|
+
keyValueStore?: IKeyValueStore;
|
|
72
|
+
/**
|
|
73
|
+
* Per-function alarm configuration. Defaults to the three AWS-recommended
|
|
74
|
+
* alarms (execution errors, validation errors, throttles) each with
|
|
75
|
+
* threshold 0. Set to `false` to disable all alarms for this function, or
|
|
76
|
+
* override individual alarms via their config entry.
|
|
77
|
+
*
|
|
78
|
+
* **Region requirement:** CloudFront metrics are emitted in `us-east-1`
|
|
79
|
+
* only. CloudWatch alarms are regional, so these alarms will only fire if
|
|
80
|
+
* the containing stack is deployed in `us-east-1`. The builder emits a
|
|
81
|
+
* synth-time warning if this isn't the case.
|
|
82
|
+
*
|
|
83
|
+
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/monitoring-functions.html
|
|
84
|
+
*/
|
|
85
|
+
recommendedAlarms?: FunctionAlarmConfig | false;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Configuration for the distribution's default cache behavior.
|
|
89
|
+
*
|
|
90
|
+
* The origin is set separately via {@link IDistributionBuilder.origin}. The
|
|
91
|
+
* `functionAssociations` field from {@link AddBehaviorOptions} is replaced by
|
|
92
|
+
* {@link functions}, which takes {@link InlineFunctionDefinition}s — the
|
|
93
|
+
* builder owns the CloudFront Function constructs so it can emit alarms for
|
|
94
|
+
* them.
|
|
95
|
+
*/
|
|
96
|
+
export interface DefaultBehaviorConfig extends Omit<AddBehaviorOptions, "functionAssociations"> {
|
|
97
|
+
/**
|
|
98
|
+
* CloudFront Functions to associate with the default behavior. At most one
|
|
99
|
+
* function per {@link FunctionEventType} is allowed.
|
|
100
|
+
*/
|
|
101
|
+
functions?: InlineFunctionDefinition[];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Configuration for a path-pattern cache behavior attached to the distribution
|
|
105
|
+
* via {@link IDistributionBuilder.behavior}.
|
|
106
|
+
*
|
|
107
|
+
* Unlike {@link DefaultBehaviorConfig}, `origin` is required. It may be a
|
|
108
|
+
* concrete {@link IOrigin} or a {@link Resolvable} (typically a {@link ref})
|
|
109
|
+
* for cross-component wiring.
|
|
110
|
+
*/
|
|
111
|
+
export interface AdditionalBehaviorConfig extends Omit<BehaviorOptions, "origin" | "functionAssociations"> {
|
|
112
|
+
/** The origin for this behavior, concrete or resolved at build time. */
|
|
113
|
+
origin: Resolvable<IOrigin>;
|
|
114
|
+
/**
|
|
115
|
+
* CloudFront Functions to associate with this behavior. At most one
|
|
116
|
+
* function per {@link FunctionEventType} is allowed.
|
|
117
|
+
*/
|
|
118
|
+
functions?: InlineFunctionDefinition[];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Configures how CloudFront standard access logs are handled. Pass `false`
|
|
122
|
+
* to disable logging; pass an object to wire a destination, prefix,
|
|
123
|
+
* include cookies, or customize the auto-created sub-builder.
|
|
124
|
+
*
|
|
125
|
+
* `configure` cannot be combined with `destination` — a user-managed
|
|
126
|
+
* destination is not built by this builder.
|
|
127
|
+
*/
|
|
128
|
+
export type AccessLogsConfig = false | {
|
|
129
|
+
destination?: IBucket;
|
|
130
|
+
prefix?: string;
|
|
131
|
+
includeCookies?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Customize the auto-created logging sub-builder. Receives a builder
|
|
134
|
+
* pre-seeded with `versioned: false`, `objectOwnership:
|
|
135
|
+
* BUCKET_OWNER_PREFERRED`, `removalPolicy: RETAIN`, and recursive
|
|
136
|
+
* S3 server access logging disabled.
|
|
137
|
+
*/
|
|
138
|
+
configure?: (b: IBucketBuilder) => IBucketBuilder;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Configuration properties for the CloudFront distribution builder.
|
|
142
|
+
*
|
|
143
|
+
* Extends the CDK {@link DistributionProps} with additional builder-specific
|
|
144
|
+
* options. `defaultBehavior` accepts a {@link DefaultBehaviorConfig} with
|
|
145
|
+
* inline function definitions; additional behaviors are added via the
|
|
146
|
+
* {@link IDistributionBuilder.behavior} method rather than the raw
|
|
147
|
+
* `additionalBehaviors` record.
|
|
148
|
+
*
|
|
149
|
+
* The CDK `enableLogging`, `logBucket`, `logFilePrefix`, and
|
|
150
|
+
* `logIncludesCookies` props are replaced by {@link accessLogs}, which
|
|
151
|
+
* auto-creates a logging bucket with secure defaults by default.
|
|
152
|
+
*/
|
|
153
|
+
export interface DistributionBuilderProps extends Omit<DistributionProps, "defaultBehavior" | "additionalBehaviors" | "enableLogging" | "logBucket" | "logFilePrefix" | "logIncludesCookies" | "certificate"> {
|
|
154
|
+
/** See {@link AccessLogsConfig}. Defaults to `{ prefix: "logs/" }`. */
|
|
155
|
+
accessLogs?: AccessLogsConfig;
|
|
156
|
+
/**
|
|
157
|
+
* The ACM certificate to associate with the distribution for HTTPS.
|
|
158
|
+
*
|
|
159
|
+
* Accepts a concrete {@link ICertificate} or a {@link Resolvable} —
|
|
160
|
+
* typically a {@link Ref} produced by a composed `@composurecdk/acm`
|
|
161
|
+
* certificate builder. The certificate must be issued in `us-east-1`.
|
|
162
|
+
*/
|
|
163
|
+
certificate?: Resolvable<ICertificate>;
|
|
164
|
+
/**
|
|
165
|
+
* Configuration for the default cache behavior. The origin is set via
|
|
166
|
+
* {@link IDistributionBuilder.origin}. Inline CloudFront Functions declared
|
|
167
|
+
* in `functions` are created by the builder and receive path-scoped alarms
|
|
168
|
+
* automatically.
|
|
169
|
+
*/
|
|
170
|
+
defaultBehavior?: DefaultBehaviorConfig;
|
|
171
|
+
/**
|
|
172
|
+
* Configuration for AWS-recommended CloudWatch alarms at the **distribution**
|
|
173
|
+
* level (5xx error rate, origin latency).
|
|
174
|
+
*
|
|
175
|
+
* Per-function alarm shapes (`FunctionExecutionErrors`,
|
|
176
|
+
* `FunctionValidationErrors`, `FunctionThrottles`) are configured per
|
|
177
|
+
* function via {@link InlineFunctionDefinition.recommendedAlarms}, because
|
|
178
|
+
* their correct disposition depends on the behavior the function is
|
|
179
|
+
* attached to. The kill switch below (`recommendedAlarms: false`) still
|
|
180
|
+
* applies to function alarms — see below.
|
|
181
|
+
*
|
|
182
|
+
* **Region requirement:** CloudFront metrics are emitted in `us-east-1`
|
|
183
|
+
* only. CloudWatch alarms are regional, so every alarm created by this
|
|
184
|
+
* builder will only fire if the containing stack is deployed in
|
|
185
|
+
* `us-east-1`. The builder emits a synth-time warning if this isn't the
|
|
186
|
+
* case. For multi-region deployments, set `recommendedAlarms: false` here
|
|
187
|
+
* and use {@link createCloudFrontAlarmBuilder} routed to a `us-east-1`
|
|
188
|
+
* stack via `compose().withStacks()`.
|
|
189
|
+
*
|
|
190
|
+
* Set to `false` to disable all recommended alarms (both distribution-level
|
|
191
|
+
* and per-function). Custom alarms added via
|
|
192
|
+
* {@link IDistributionBuilder.addAlarm} are unaffected. To disable a single
|
|
193
|
+
* function's alarms, set `recommendedAlarms: false` on the corresponding
|
|
194
|
+
* {@link InlineFunctionDefinition}.
|
|
195
|
+
*
|
|
196
|
+
* No alarm actions are configured by default since notification methods
|
|
197
|
+
* are user-specific. Access alarms from the build result or use an
|
|
198
|
+
* `afterBuild` hook to apply actions.
|
|
199
|
+
*
|
|
200
|
+
* @example Tighter dist-level threshold; function alarms unchanged.
|
|
201
|
+
* ```ts
|
|
202
|
+
* createDistributionBuilder()
|
|
203
|
+
* .origin(siteOrigin)
|
|
204
|
+
* .recommendedAlarms({ errorRate: { threshold: 2 } });
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
207
|
+
* @example Multi-region setup — suppress all alarms here, recreate them in
|
|
208
|
+
* a `us-east-1` stack via {@link createCloudFrontAlarmBuilder}.
|
|
209
|
+
* ```ts
|
|
210
|
+
* createDistributionBuilder()
|
|
211
|
+
* .origin(siteOrigin)
|
|
212
|
+
* .recommendedAlarms(false);
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#CloudFront
|
|
216
|
+
*/
|
|
217
|
+
recommendedAlarms?: DistributionAlarmConfig | false;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* The build output of an {@link IDistributionBuilder}. Contains the CDK
|
|
221
|
+
* constructs created during {@link Lifecycle.build}, keyed by role.
|
|
222
|
+
*/
|
|
223
|
+
export interface DistributionBuilderResult {
|
|
224
|
+
/** The CloudFront distribution construct created by the builder. */
|
|
225
|
+
distribution: Distribution;
|
|
226
|
+
/**
|
|
227
|
+
* The S3 bucket created for access logging, or `undefined` if access
|
|
228
|
+
* logging was disabled or the user provided their own bucket.
|
|
229
|
+
*/
|
|
230
|
+
accessLogsBucket?: Bucket;
|
|
231
|
+
/**
|
|
232
|
+
* CloudFront Functions created by the builder for inline function
|
|
233
|
+
* definitions, keyed by `<behaviorScope><EventType>` —
|
|
234
|
+
* e.g. `defaultBehaviorViewerRequest`, `behaviorApiStarViewerRequest`.
|
|
235
|
+
* Each entry bundles the {@link CfFunction} with the behavior context
|
|
236
|
+
* (`pathPattern`, `eventType`) and the per-function `recommendedAlarms`
|
|
237
|
+
* config the user supplied. Empty if no inline functions were declared.
|
|
238
|
+
*/
|
|
239
|
+
functions: Record<string, FunctionEntry>;
|
|
240
|
+
/**
|
|
241
|
+
* CloudWatch alarms created for the distribution and its inline functions,
|
|
242
|
+
* keyed by alarm name. Distribution-level keys: `errorRate`, `originLatency`.
|
|
243
|
+
* Function-level keys are prefixed by behavior scope and event type —
|
|
244
|
+
* e.g. `defaultBehaviorViewerRequestExecutionErrors`.
|
|
245
|
+
*
|
|
246
|
+
* Includes both recommended alarms and custom alarms added via
|
|
247
|
+
* {@link IDistributionBuilder.addAlarm}. Empty when `recommendedAlarms` is
|
|
248
|
+
* `false` and no custom alarms were added. No alarm actions are configured.
|
|
249
|
+
*/
|
|
250
|
+
alarms: Record<string, Alarm>;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* A fluent builder for configuring and creating a CloudFront distribution.
|
|
254
|
+
*
|
|
255
|
+
* Properties from CDK {@link DistributionProps} are exposed as overloaded
|
|
256
|
+
* getter/setter methods. The origin is set via {@link origin}, which accepts
|
|
257
|
+
* a concrete {@link IOrigin} or a {@link Ref} for cross-component wiring.
|
|
258
|
+
* Additional cache behaviors are added via {@link behavior}, which takes a
|
|
259
|
+
* path pattern and a config including its own origin and inline functions.
|
|
260
|
+
*
|
|
261
|
+
* The builder implements {@link Lifecycle}, so it can be used directly as a
|
|
262
|
+
* component in a {@link compose | composed system}. When built, it creates a
|
|
263
|
+
* CloudFront distribution, any inline CloudFront Functions declared on its
|
|
264
|
+
* behaviors, and AWS-recommended alarms scoped per-behavior.
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```ts
|
|
268
|
+
* const cdn = createDistributionBuilder()
|
|
269
|
+
* .origin(siteOrigin)
|
|
270
|
+
* .defaultBehavior({
|
|
271
|
+
* functions: [{
|
|
272
|
+
* eventType: FunctionEventType.VIEWER_REQUEST,
|
|
273
|
+
* code: FunctionCode.fromFile({ filePath: "src/edge/rewrite.js" }),
|
|
274
|
+
* }],
|
|
275
|
+
* })
|
|
276
|
+
* .behavior("/api/*", {
|
|
277
|
+
* origin: apiOrigin,
|
|
278
|
+
* cachePolicy: CachePolicy.CACHING_DISABLED,
|
|
279
|
+
* functions: [{
|
|
280
|
+
* eventType: FunctionEventType.VIEWER_REQUEST,
|
|
281
|
+
* code: FunctionCode.fromFile({ filePath: "src/edge/api-auth.js" }),
|
|
282
|
+
* }],
|
|
283
|
+
* });
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
export type IDistributionBuilder = ITaggedBuilder<DistributionBuilderProps, DistributionBuilder>;
|
|
287
|
+
declare class DistributionBuilder implements Lifecycle<DistributionBuilderResult> {
|
|
288
|
+
#private;
|
|
289
|
+
props: Partial<DistributionBuilderProps>;
|
|
290
|
+
addAlarm(key: string, configure: (alarm: AlarmDefinitionBuilder<Distribution>) => AlarmDefinitionBuilder<Distribution>): this;
|
|
291
|
+
/**
|
|
292
|
+
* Sets the default origin for the distribution.
|
|
293
|
+
*
|
|
294
|
+
* Accepts a concrete {@link IOrigin} or a {@link Ref} that resolves to one
|
|
295
|
+
* at build time — enabling cross-component wiring with S3 buckets.
|
|
296
|
+
*
|
|
297
|
+
* @param origin - The origin or a Ref to one.
|
|
298
|
+
* @returns This builder for chaining.
|
|
299
|
+
*/
|
|
300
|
+
origin(origin: Resolvable<IOrigin>): this;
|
|
301
|
+
/**
|
|
302
|
+
* Adds an additional cache behavior for a path pattern. The behavior's
|
|
303
|
+
* origin is required (concrete or Resolvable). Any inline functions are
|
|
304
|
+
* created by the builder and receive per-behavior alarms scoped to the
|
|
305
|
+
* path pattern.
|
|
306
|
+
*
|
|
307
|
+
* @throws If a behavior for the same path pattern has already been added.
|
|
308
|
+
*/
|
|
309
|
+
behavior(pathPattern: string, config: AdditionalBehaviorConfig): this;
|
|
310
|
+
/** @internal — see ADR-0005. */
|
|
311
|
+
[COPY_STATE](target: DistributionBuilder): void;
|
|
312
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): DistributionBuilderResult;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Creates a new {@link IDistributionBuilder} for configuring a CloudFront distribution.
|
|
316
|
+
*
|
|
317
|
+
* This is the entry point for defining a CloudFront distribution component.
|
|
318
|
+
* The returned builder exposes every {@link DistributionBuilderProps} property
|
|
319
|
+
* as a fluent setter/getter, plus {@link IDistributionBuilder.origin | origin()}
|
|
320
|
+
* for setting the default origin with Ref support and
|
|
321
|
+
* {@link IDistributionBuilder.behavior | behavior()} for path-pattern behaviors.
|
|
322
|
+
* It implements {@link Lifecycle} for use with {@link compose}.
|
|
323
|
+
*
|
|
324
|
+
* @returns A fluent builder for a CloudFront distribution.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```ts
|
|
328
|
+
* const cdn = createDistributionBuilder()
|
|
329
|
+
* .origin(ref<BucketBuilderResult>("site", (r) =>
|
|
330
|
+
* S3BucketOrigin.withOriginAccessControl(r.bucket)))
|
|
331
|
+
* .defaultBehavior({
|
|
332
|
+
* functions: [{
|
|
333
|
+
* eventType: FunctionEventType.VIEWER_REQUEST,
|
|
334
|
+
* code: FunctionCode.fromFile({ filePath: "src/edge/rewrite.js" }),
|
|
335
|
+
* }],
|
|
336
|
+
* })
|
|
337
|
+
* .behavior("/api/*", {
|
|
338
|
+
* origin: apiOrigin,
|
|
339
|
+
* cachePolicy: CachePolicy.CACHING_DISABLED,
|
|
340
|
+
* });
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
export declare function createDistributionBuilder(): IDistributionBuilder;
|
|
344
|
+
export {};
|
|
345
|
+
//# sourceMappingURL=distribution-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distribution-builder.d.ts","sourceRoot":"","sources":["../../src/distribution-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,QAAQ,IAAI,UAAU,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
|
|
1
1
|
import { Distribution, } from "aws-cdk-lib/aws-cloudfront";
|
|
2
2
|
import { ObjectOwnership } from "aws-cdk-lib/aws-s3";
|
|
3
3
|
import { RemovalPolicy } from "aws-cdk-lib";
|
|
4
|
-
import {
|
|
4
|
+
import { COPY_STATE, resolve } from "@composurecdk/core";
|
|
5
|
+
import { taggedBuilder } from "@composurecdk/cloudformation";
|
|
5
6
|
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
6
7
|
import { DEFAULT_ACCESS_LOG_BUCKET_LIFECYCLE_RULES, createBucketBuilder, } from "@composurecdk/s3";
|
|
7
8
|
import { DISTRIBUTION_DEFAULTS } from "./defaults.js";
|
|
@@ -57,6 +58,15 @@ class DistributionBuilder {
|
|
|
57
58
|
this.#additionalBehaviors.set(pathPattern, config);
|
|
58
59
|
return this;
|
|
59
60
|
}
|
|
61
|
+
/** @internal — see ADR-0005. */
|
|
62
|
+
[COPY_STATE](target) {
|
|
63
|
+
target.#origin = this.#origin;
|
|
64
|
+
for (const [k, v] of this.#additionalBehaviors)
|
|
65
|
+
target.#additionalBehaviors.set(k, v);
|
|
66
|
+
for (const [k, v] of this.#behaviorSlugs)
|
|
67
|
+
target.#behaviorSlugs.set(k, v);
|
|
68
|
+
target.#customAlarms.push(...this.#customAlarms);
|
|
69
|
+
}
|
|
60
70
|
build(scope, id, context) {
|
|
61
71
|
const resolvedOrigin = this.#origin ? resolve(this.#origin, context ?? {}) : undefined;
|
|
62
72
|
if (!resolvedOrigin) {
|
|
@@ -132,7 +142,7 @@ class DistributionBuilder {
|
|
|
132
142
|
* ```
|
|
133
143
|
*/
|
|
134
144
|
export function createDistributionBuilder() {
|
|
135
|
-
return
|
|
145
|
+
return taggedBuilder(DistributionBuilder);
|
|
136
146
|
}
|
|
137
147
|
function resolveAccessLogs(scope, id, cfg) {
|
|
138
148
|
if (cfg === false || cfg === undefined) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distribution-builder.js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G,CAAC,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACxF,CAAC;IAEF,IAAI,GAAG,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAClC,IAAI,GAAG,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CACb,kEAAkE;gBAChE,uEAAuE,CAC1E,CAAC;QACJ,CAAC;QACD,OAAO;YACL,cAAc,EAAE;gBACd,aAAa,EAAE,IAAI;gBACnB,SAAS,EAAE,GAAG,CAAC,WAAW;gBAC1B,GAAG,MAAM;aACV;SACF,CAAC;IACJ,CAAC;IAED,IAAI,UAAU,GAAG,mBAAmB,EAAE;SACnC,gBAAgB,CAAC,KAAK,CAAC;SACvB,SAAS,CAAC,KAAK,CAAC;QACjB,oFAAoF;SACnF,eAAe,CAAC,eAAe,CAAC,sBAAsB,CAAC;SACvD,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC;SACnC,cAAc,CAAC,yCAAyC,CAAC,CAAC;IAC7D,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;QAClB,UAAU,GAAG,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,gBAAgB,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC,MAAM,CAAC;IAE3E,OAAO;QACL,gBAAgB;QAChB,cAAc,EAAE;YACd,aAAa,EAAE,IAAI;YACnB,SAAS,EAAE,gBAAgB;YAC3B,GAAG,MAAM;SACV;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createDistributionBuilder, type AccessLogsConfig, type DistributionBuilderProps, type DistributionBuilderResult, type IDistributionBuilder, type DefaultBehaviorConfig, type AdditionalBehaviorConfig, type InlineFunctionDefinition, } from "./distribution-builder.js";
|
|
2
|
+
export { createCloudFrontAlarmBuilder, type CloudFrontAlarmBuilderProps, type CloudFrontAlarmBuilderResult, type ICloudFrontAlarmBuilder, } from "./cloudfront-alarm-builder.js";
|
|
3
|
+
export { DISTRIBUTION_DEFAULTS, INLINE_FUNCTION_DEFAULTS } from "./defaults.js";
|
|
4
|
+
export { type DistributionAlarmConfig, type FunctionAlarmConfig } from "./alarm-config.js";
|
|
5
|
+
export { DISTRIBUTION_ALARM_DEFAULTS, FUNCTION_ALARM_DEFAULTS } from "./alarm-defaults.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,4BAA4B,EAC5B,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,GAC7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,KAAK,uBAAuB,EAAE,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,GAQ1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,4BAA4B,GAI7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEhF,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC"}
|