@composurecdk/route53 0.3.3
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/README.md +122 -0
- package/dist/a-record-builder.d.ts +56 -0
- package/dist/a-record-builder.d.ts.map +1 -0
- package/dist/a-record-builder.js +35 -0
- package/dist/a-record-builder.js.map +1 -0
- package/dist/aaaa-record-builder.d.ts +44 -0
- package/dist/aaaa-record-builder.d.ts.map +1 -0
- package/dist/aaaa-record-builder.js +36 -0
- package/dist/aaaa-record-builder.js.map +1 -0
- package/dist/alias-targets.d.ts +34 -0
- package/dist/alias-targets.d.ts.map +1 -0
- package/dist/alias-targets.js +45 -0
- package/dist/alias-targets.js.map +1 -0
- package/dist/cname-record-builder.d.ts +42 -0
- package/dist/cname-record-builder.d.ts.map +1 -0
- package/dist/cname-record-builder.js +40 -0
- package/dist/cname-record-builder.js.map +1 -0
- package/dist/defaults.d.ts +36 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +56 -0
- package/dist/defaults.js.map +1 -0
- package/dist/hosted-zone-builder.d.ts +75 -0
- package/dist/hosted-zone-builder.d.ts.map +1 -0
- package/dist/hosted-zone-builder.js +49 -0
- package/dist/hosted-zone-builder.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/txt-record-builder.d.ts +38 -0
- package/dist/txt-record-builder.d.ts.map +1 -0
- package/dist/txt-record-builder.js +34 -0
- package/dist/txt-record-builder.js.map +1 -0
- package/package.json +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# @composurecdk/route53
|
|
2
|
+
|
|
3
|
+
Route 53 hosted zone and record builders for [ComposureCDK](../../README.md).
|
|
4
|
+
|
|
5
|
+
This package provides fluent builders for Route 53 public hosted zones and for the record types most commonly needed when fronting an AWS workload (A/AAAA alias, CNAME, TXT). It wraps the CDK [aws-route53](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53-readme.html) constructs — refer to the CDK documentation for the full set of configurable properties.
|
|
6
|
+
|
|
7
|
+
## Hosted Zone Builder
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createHostedZoneBuilder } from "@composurecdk/route53";
|
|
11
|
+
|
|
12
|
+
const zone = createHostedZoneBuilder()
|
|
13
|
+
.zoneName("example.com")
|
|
14
|
+
.comment("Primary customer-facing domain")
|
|
15
|
+
.build(stack, "SiteZone");
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Every [PublicHostedZoneProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53.PublicHostedZoneProps.html) property is available as a fluent setter on the builder.
|
|
19
|
+
|
|
20
|
+
### Query logging
|
|
21
|
+
|
|
22
|
+
Route 53 is a global service, but DNS query logs are emitted in `us-east-1` only — the CloudWatch log group that receives them must live there regardless of where the hosted zone is declared. This is an AWS service constraint, not a restriction on where your hosted zone or records can live.
|
|
23
|
+
|
|
24
|
+
Supply a pre-configured log group via `.queryLogsLogGroupArn(arn)`. The log group must:
|
|
25
|
+
|
|
26
|
+
- Be in `us-east-1`.
|
|
27
|
+
- Have a resource policy granting `route53.amazonaws.com` permission to `logs:PutLogEvents` and `logs:CreateLogStream`.
|
|
28
|
+
|
|
29
|
+
Auto-creating the log group and resource policy on the user's behalf is planned — see [#44](https://github.com/laazyj/composureCDK/issues/44). Once implemented, enabling query logging will become a single opt-in property with the log group + resource policy wired by default.
|
|
30
|
+
|
|
31
|
+
## Record Builders
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import {
|
|
35
|
+
createARecordBuilder,
|
|
36
|
+
createAaaaRecordBuilder,
|
|
37
|
+
createCnameRecordBuilder,
|
|
38
|
+
createTxtRecordBuilder,
|
|
39
|
+
cloudfrontAliasTarget,
|
|
40
|
+
} from "@composurecdk/route53";
|
|
41
|
+
|
|
42
|
+
createARecordBuilder()
|
|
43
|
+
.zone(zone)
|
|
44
|
+
.target(cloudfrontAliasTarget(distribution))
|
|
45
|
+
.build(stack, "ApexAlias");
|
|
46
|
+
|
|
47
|
+
createTxtRecordBuilder()
|
|
48
|
+
.zone(zone)
|
|
49
|
+
.recordName("_dmarc")
|
|
50
|
+
.values(["v=DMARC1; p=reject"])
|
|
51
|
+
.build(stack, "Dmarc");
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Alias targets
|
|
55
|
+
|
|
56
|
+
For AWS-service records, prefer A/AAAA alias records over CNAMEs. Alias records:
|
|
57
|
+
|
|
58
|
+
- Are free to resolve (CNAMEs are billed per query).
|
|
59
|
+
- Work at the zone apex (CNAMEs cannot coexist with the mandatory apex SOA/NS records).
|
|
60
|
+
- Resolve in a single hop (CNAMEs chain to a second lookup).
|
|
61
|
+
- Track AWS-managed DNS changes automatically (CNAMEs must be updated manually if the target's DNS name changes).
|
|
62
|
+
- Support both IPv4 (A) and IPv6 (AAAA) from the same alias target.
|
|
63
|
+
|
|
64
|
+
Use `createCnameRecordBuilder` only when the target is not an AWS resource (or the AWS resource does not expose an alias target), and never at the zone apex.
|
|
65
|
+
|
|
66
|
+
| Helper | Points at |
|
|
67
|
+
| ------------------------------------- | ------------------------------------------------ |
|
|
68
|
+
| `cloudfrontAliasTarget(distribution)` | A `cloudfront.IDistribution` |
|
|
69
|
+
| `apiGatewayAliasTarget(api)` | An `apigateway.RestApiBase` with a custom domain |
|
|
70
|
+
| `apiGatewayDomainAliasTarget(domain)` | A shared `apigateway.DomainName` |
|
|
71
|
+
|
|
72
|
+
Each helper accepts a `Resolvable`, so targets produced by other composed components (e.g. `@composurecdk/cloudfront`) can be wired in via `ref()`.
|
|
73
|
+
|
|
74
|
+
## Secure Defaults
|
|
75
|
+
|
|
76
|
+
| Builder | Property | Default | Rationale |
|
|
77
|
+
| -------------------------- | ---------------- | --------------------- | ------------------------------------------------------- |
|
|
78
|
+
| `createHostedZoneBuilder` | `addTrailingDot` | `true` | Matches RFC 1035 and the CDK default; unambiguous apex. |
|
|
79
|
+
| `createARecordBuilder` | `ttl` | `Duration.minutes(5)` | Balances propagation latency against DNS cache churn. |
|
|
80
|
+
| `createAaaaRecordBuilder` | `ttl` | `Duration.minutes(5)` | Same rationale as A records. |
|
|
81
|
+
| `createCnameRecordBuilder` | `ttl` | `Duration.minutes(5)` | Same rationale as A records. |
|
|
82
|
+
| `createTxtRecordBuilder` | `ttl` | `Duration.minutes(5)` | Same rationale as A records. |
|
|
83
|
+
|
|
84
|
+
The defaults are exported as `HOSTED_ZONE_DEFAULTS`, `A_RECORD_DEFAULTS`, `AAAA_RECORD_DEFAULTS`, `CNAME_RECORD_DEFAULTS`, and `TXT_RECORD_DEFAULTS` for visibility and testing.
|
|
85
|
+
|
|
86
|
+
## Recommended Alarms
|
|
87
|
+
|
|
88
|
+
Route 53 health checks expose a `HealthCheckStatus` metric that [AWS recommends alarming on](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Route53). This package does not yet expose a `HealthCheckBuilder`; once it does, the recommended alarm will be enabled by default alongside the health check. Tracked in [#45](https://github.com/laazyj/composureCDK/issues/45).
|
|
89
|
+
|
|
90
|
+
## Composing with ACM and CloudFront
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { compose, ref } from "@composurecdk/core";
|
|
94
|
+
import { createCertificateBuilder, type CertificateBuilderResult } from "@composurecdk/acm";
|
|
95
|
+
import {
|
|
96
|
+
createDistributionBuilder,
|
|
97
|
+
type DistributionBuilderResult,
|
|
98
|
+
} from "@composurecdk/cloudfront";
|
|
99
|
+
import {
|
|
100
|
+
createHostedZoneBuilder,
|
|
101
|
+
createARecordBuilder,
|
|
102
|
+
cloudfrontAliasTarget,
|
|
103
|
+
type HostedZoneBuilderResult,
|
|
104
|
+
} from "@composurecdk/route53";
|
|
105
|
+
|
|
106
|
+
compose(
|
|
107
|
+
{
|
|
108
|
+
zone: createHostedZoneBuilder().zoneName("example.com"),
|
|
109
|
+
cert: createCertificateBuilder()
|
|
110
|
+
.domainName("example.com")
|
|
111
|
+
.validationZone(ref("zone", (r: HostedZoneBuilderResult) => r.hostedZone)),
|
|
112
|
+
cdn: createDistributionBuilder()
|
|
113
|
+
.domainNames(["example.com"])
|
|
114
|
+
.certificate(ref("cert", (r: CertificateBuilderResult) => r.certificate))
|
|
115
|
+
.origin(/* ... */),
|
|
116
|
+
apex: createARecordBuilder()
|
|
117
|
+
.zone(ref("zone", (r: HostedZoneBuilderResult) => r.hostedZone))
|
|
118
|
+
.target(cloudfrontAliasTarget(ref("cdn", (r: DistributionBuilderResult) => r.distribution))),
|
|
119
|
+
},
|
|
120
|
+
{ zone: [], cert: ["zone"], cdn: ["cert"], apex: ["zone", "cdn"] },
|
|
121
|
+
).build(stack, "Site");
|
|
122
|
+
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ARecord, type ARecordProps, type IHostedZone, type RecordTarget } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import { type IConstruct } from "constructs";
|
|
3
|
+
import { type IBuilder, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
4
|
+
/**
|
|
5
|
+
* Configuration properties for the Route53 A record builder.
|
|
6
|
+
*
|
|
7
|
+
* Extends the CDK {@link ARecordProps} but replaces `zone` and `target` with
|
|
8
|
+
* {@link Resolvable} variants so they can be wired from other components in a
|
|
9
|
+
* composed system via {@link ref}.
|
|
10
|
+
*/
|
|
11
|
+
export interface ARecordBuilderProps extends Omit<ARecordProps, "zone" | "target"> {
|
|
12
|
+
/**
|
|
13
|
+
* The hosted zone in which to create the record. Accepts a {@link Resolvable}
|
|
14
|
+
* so a zone produced by a composed {@link createHostedZoneBuilder} can be
|
|
15
|
+
* wired in via {@link ref}.
|
|
16
|
+
*/
|
|
17
|
+
zone?: Resolvable<IHostedZone>;
|
|
18
|
+
/**
|
|
19
|
+
* The record target. Accepts a {@link Resolvable} so alias targets derived
|
|
20
|
+
* from composed components (e.g. a CloudFront distribution) can be wired in
|
|
21
|
+
* via {@link ref} or the helpers in `./alias-targets.js`.
|
|
22
|
+
*/
|
|
23
|
+
target?: Resolvable<RecordTarget>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The build output of an {@link IARecordBuilder}.
|
|
27
|
+
*/
|
|
28
|
+
export interface ARecordBuilderResult {
|
|
29
|
+
/** The Route53 A record construct created by the builder. */
|
|
30
|
+
record: ARecord;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A fluent builder for configuring and creating a Route53 A record (typically
|
|
34
|
+
* an alias record pointing at a CloudFront distribution, ALB, API Gateway
|
|
35
|
+
* custom domain, or another A-record-capable target).
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const apex = createARecordBuilder()
|
|
40
|
+
* .zone(ref("zone", (r: HostedZoneBuilderResult) => r.hostedZone))
|
|
41
|
+
* .target(cloudfrontAliasTarget(ref("cdn", (r: DistributionBuilderResult) => r.distribution)));
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export type IARecordBuilder = IBuilder<ARecordBuilderProps, ARecordBuilder>;
|
|
45
|
+
declare class ARecordBuilder implements Lifecycle<ARecordBuilderResult> {
|
|
46
|
+
props: Partial<ARecordBuilderProps>;
|
|
47
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): ARecordBuilderResult;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new {@link IARecordBuilder} for configuring a Route53 A record.
|
|
51
|
+
*
|
|
52
|
+
* @returns A fluent builder for a Route53 A record.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createARecordBuilder(): IARecordBuilder;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=a-record-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a-record-builder.d.ts","sourceRoot":"","sources":["../src/a-record-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,SAAS,EAEd,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAG5B;;;;;;GAMG;AACH,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,CAAC;IAChF;;;;OAIG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IAE/B;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,6DAA6D;IAC7D,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;AAE5E,cAAM,cAAe,YAAW,SAAS,CAAC,oBAAoB,CAAC;IAC7D,KAAK,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAM;IAEzC,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,oBAAoB;CAwB7F;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,eAAe,CAEtD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ARecord, } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import { Builder, resolve, } from "@composurecdk/core";
|
|
3
|
+
import { A_RECORD_DEFAULTS } from "./defaults.js";
|
|
4
|
+
class ARecordBuilder {
|
|
5
|
+
props = {};
|
|
6
|
+
build(scope, id, context) {
|
|
7
|
+
const { zone, target, ...rest } = this.props;
|
|
8
|
+
if (!zone) {
|
|
9
|
+
throw new Error(`ARecordBuilder "${id}" requires a zone. Call .zone() with an IHostedZone.`);
|
|
10
|
+
}
|
|
11
|
+
if (!target) {
|
|
12
|
+
throw new Error(`ARecordBuilder "${id}" requires a target. Call .target() with a RecordTarget.`);
|
|
13
|
+
}
|
|
14
|
+
const resolvedContext = context ?? {};
|
|
15
|
+
const resolvedTarget = resolve(target, resolvedContext);
|
|
16
|
+
const isAlias = resolvedTarget.aliasTarget !== undefined;
|
|
17
|
+
const mergedProps = {
|
|
18
|
+
...(isAlias ? {} : A_RECORD_DEFAULTS),
|
|
19
|
+
...rest,
|
|
20
|
+
zone: resolve(zone, resolvedContext),
|
|
21
|
+
target: resolvedTarget,
|
|
22
|
+
};
|
|
23
|
+
const record = new ARecord(scope, id, mergedProps);
|
|
24
|
+
return { record };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new {@link IARecordBuilder} for configuring a Route53 A record.
|
|
29
|
+
*
|
|
30
|
+
* @returns A fluent builder for a Route53 A record.
|
|
31
|
+
*/
|
|
32
|
+
export function createARecordBuilder() {
|
|
33
|
+
return Builder(ARecordBuilder);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=a-record-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a-record-builder.js","sourceRoot":"","sources":["../src/a-record-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,GAIR,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,OAAO,EAGP,OAAO,GAER,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AA+ClD,MAAM,cAAc;IAClB,KAAK,GAAiC,EAAE,CAAC;IAEzC,KAAK,CAAC,KAAiB,EAAE,EAAU,EAAE,OAAgC;QACnE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,mBAAmB,EAAE,sDAAsD,CAAC,CAAC;QAC/F,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACb,mBAAmB,EAAE,0DAA0D,CAChF,CAAC;QACJ,CAAC;QAED,MAAM,eAAe,GAAG,OAAO,IAAI,EAAE,CAAC;QACtC,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QACxD,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,KAAK,SAAS,CAAC;QACzD,MAAM,WAAW,GAAG;YAClB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC;YACrC,GAAG,IAAI;YACP,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC;YACpC,MAAM,EAAE,cAAc;SACP,CAAC;QAElB,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;QACnD,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,OAAO,CAAsC,cAAc,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AaaaRecord, type AaaaRecordProps, type IHostedZone, type RecordTarget } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import { type IConstruct } from "constructs";
|
|
3
|
+
import { type IBuilder, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
4
|
+
/**
|
|
5
|
+
* Configuration properties for the Route53 AAAA (IPv6) record builder.
|
|
6
|
+
*
|
|
7
|
+
* Extends the CDK {@link AaaaRecordProps} but replaces `zone` and `target`
|
|
8
|
+
* with {@link Resolvable} variants so they can be wired from other components
|
|
9
|
+
* in a composed system.
|
|
10
|
+
*/
|
|
11
|
+
export interface AaaaRecordBuilderProps extends Omit<AaaaRecordProps, "zone" | "target"> {
|
|
12
|
+
/** The hosted zone in which to create the record. */
|
|
13
|
+
zone?: Resolvable<IHostedZone>;
|
|
14
|
+
/** The record target. */
|
|
15
|
+
target?: Resolvable<RecordTarget>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The build output of an {@link IAaaaRecordBuilder}.
|
|
19
|
+
*/
|
|
20
|
+
export interface AaaaRecordBuilderResult {
|
|
21
|
+
/** The Route53 AAAA record construct created by the builder. */
|
|
22
|
+
record: AaaaRecord;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A fluent builder for configuring and creating a Route53 AAAA (IPv6) record.
|
|
26
|
+
*
|
|
27
|
+
* Use this alongside an A record to expose a CloudFront distribution or ALB
|
|
28
|
+
* over both IPv4 and IPv6 — AWS alias targets support both families from a
|
|
29
|
+
* single resource.
|
|
30
|
+
*/
|
|
31
|
+
export type IAaaaRecordBuilder = IBuilder<AaaaRecordBuilderProps, AaaaRecordBuilder>;
|
|
32
|
+
declare class AaaaRecordBuilder implements Lifecycle<AaaaRecordBuilderResult> {
|
|
33
|
+
props: Partial<AaaaRecordBuilderProps>;
|
|
34
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): AaaaRecordBuilderResult;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new {@link IAaaaRecordBuilder} for configuring a Route53 AAAA
|
|
38
|
+
* (IPv6) record.
|
|
39
|
+
*
|
|
40
|
+
* @returns A fluent builder for a Route53 AAAA record.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createAaaaRecordBuilder(): IAaaaRecordBuilder;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=aaaa-record-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aaaa-record-builder.d.ts","sourceRoot":"","sources":["../src/aaaa-record-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,SAAS,EAEd,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAG5B;;;;;;GAMG;AACH,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,QAAQ,CAAC;IACtF,qDAAqD;IACrD,IAAI,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IAC/B,yBAAyB;IACzB,MAAM,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,gEAAgE;IAChE,MAAM,EAAE,UAAU,CAAC;CACpB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,sBAAsB,EAAE,iBAAiB,CAAC,CAAC;AAErF,cAAM,iBAAkB,YAAW,SAAS,CAAC,uBAAuB,CAAC;IACnE,KAAK,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAM;IAE5C,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,uBAAuB;CA0BhG;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,IAAI,kBAAkB,CAE5D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AaaaRecord, } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import { Builder, resolve, } from "@composurecdk/core";
|
|
3
|
+
import { AAAA_RECORD_DEFAULTS } from "./defaults.js";
|
|
4
|
+
class AaaaRecordBuilder {
|
|
5
|
+
props = {};
|
|
6
|
+
build(scope, id, context) {
|
|
7
|
+
const { zone, target, ...rest } = this.props;
|
|
8
|
+
if (!zone) {
|
|
9
|
+
throw new Error(`AaaaRecordBuilder "${id}" requires a zone. Call .zone() with an IHostedZone.`);
|
|
10
|
+
}
|
|
11
|
+
if (!target) {
|
|
12
|
+
throw new Error(`AaaaRecordBuilder "${id}" requires a target. Call .target() with a RecordTarget.`);
|
|
13
|
+
}
|
|
14
|
+
const resolvedContext = context ?? {};
|
|
15
|
+
const resolvedTarget = resolve(target, resolvedContext);
|
|
16
|
+
const isAlias = resolvedTarget.aliasTarget !== undefined;
|
|
17
|
+
const mergedProps = {
|
|
18
|
+
...(isAlias ? {} : AAAA_RECORD_DEFAULTS),
|
|
19
|
+
...rest,
|
|
20
|
+
zone: resolve(zone, resolvedContext),
|
|
21
|
+
target: resolvedTarget,
|
|
22
|
+
};
|
|
23
|
+
const record = new AaaaRecord(scope, id, mergedProps);
|
|
24
|
+
return { record };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new {@link IAaaaRecordBuilder} for configuring a Route53 AAAA
|
|
29
|
+
* (IPv6) record.
|
|
30
|
+
*
|
|
31
|
+
* @returns A fluent builder for a Route53 AAAA record.
|
|
32
|
+
*/
|
|
33
|
+
export function createAaaaRecordBuilder() {
|
|
34
|
+
return Builder(AaaaRecordBuilder);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=aaaa-record-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aaaa-record-builder.js","sourceRoot":"","sources":["../src/aaaa-record-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,GAIX,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,OAAO,EAGP,OAAO,GAER,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAiCrD,MAAM,iBAAiB;IACrB,KAAK,GAAoC,EAAE,CAAC;IAE5C,KAAK,CAAC,KAAiB,EAAE,EAAU,EAAE,OAAgC;QACnE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CACb,sBAAsB,EAAE,sDAAsD,CAC/E,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACb,sBAAsB,EAAE,0DAA0D,CACnF,CAAC;QACJ,CAAC;QAED,MAAM,eAAe,GAAG,OAAO,IAAI,EAAE,CAAC;QACtC,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QACxD,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,KAAK,SAAS,CAAC;QACzD,MAAM,WAAW,GAAG;YAClB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC;YACxC,GAAG,IAAI;YACP,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC;YACpC,MAAM,EAAE,cAAc;SACJ,CAAC;QAErB,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,KAAK,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;QACtD,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,OAAO,CAA4C,iBAAiB,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type IDistribution } from "aws-cdk-lib/aws-cloudfront";
|
|
2
|
+
import { type IDomainName, type RestApiBase } from "aws-cdk-lib/aws-apigateway";
|
|
3
|
+
import { RecordTarget } from "aws-cdk-lib/aws-route53";
|
|
4
|
+
import { type Resolvable } from "@composurecdk/core";
|
|
5
|
+
/**
|
|
6
|
+
* Builds an alias {@link RecordTarget} for a CloudFront distribution, usable
|
|
7
|
+
* as the `target` of an A or AAAA record. Accepts a {@link Resolvable} so a
|
|
8
|
+
* distribution produced by a composed `@composurecdk/cloudfront` component
|
|
9
|
+
* can be wired in via {@link ref}.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* createARecordBuilder()
|
|
14
|
+
* .zone(ref("zone", (r: HostedZoneBuilderResult) => r.hostedZone))
|
|
15
|
+
* .target(cloudfrontAliasTarget(
|
|
16
|
+
* ref("cdn", (r: DistributionBuilderResult) => r.distribution),
|
|
17
|
+
* ));
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function cloudfrontAliasTarget(distribution: Resolvable<IDistribution>): Resolvable<RecordTarget>;
|
|
21
|
+
/**
|
|
22
|
+
* Builds an alias {@link RecordTarget} for an API Gateway REST API that has a
|
|
23
|
+
* custom domain name configured via {@link RestApiBase}. Accepts a
|
|
24
|
+
* {@link Resolvable}.
|
|
25
|
+
*/
|
|
26
|
+
export declare function apiGatewayAliasTarget(api: Resolvable<RestApiBase>): Resolvable<RecordTarget>;
|
|
27
|
+
/**
|
|
28
|
+
* Builds an alias {@link RecordTarget} for an API Gateway custom domain name
|
|
29
|
+
* (`apigateway.DomainName`). Use this when you manage the domain name resource
|
|
30
|
+
* separately from the REST API (e.g. to share a custom domain across multiple
|
|
31
|
+
* APIs). Accepts a {@link Resolvable}.
|
|
32
|
+
*/
|
|
33
|
+
export declare function apiGatewayDomainAliasTarget(domain: Resolvable<IDomainName>): Resolvable<RecordTarget>;
|
|
34
|
+
//# sourceMappingURL=alias-targets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alias-targets.d.ts","sourceRoot":"","sources":["../src/alias-targets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,UAAU,CAAC,aAAa,CAAC,GACtC,UAAU,CAAC,YAAY,CAAC,CAI1B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,UAAU,CAAC,YAAY,CAAC,CAI5F;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,GAC9B,UAAU,CAAC,YAAY,CAAC,CAI1B"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { RecordTarget } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import { ApiGateway, ApiGatewayDomain, CloudFrontTarget } from "aws-cdk-lib/aws-route53-targets";
|
|
3
|
+
import { isRef } from "@composurecdk/core";
|
|
4
|
+
/**
|
|
5
|
+
* Builds an alias {@link RecordTarget} for a CloudFront distribution, usable
|
|
6
|
+
* as the `target` of an A or AAAA record. Accepts a {@link Resolvable} so a
|
|
7
|
+
* distribution produced by a composed `@composurecdk/cloudfront` component
|
|
8
|
+
* can be wired in via {@link ref}.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* createARecordBuilder()
|
|
13
|
+
* .zone(ref("zone", (r: HostedZoneBuilderResult) => r.hostedZone))
|
|
14
|
+
* .target(cloudfrontAliasTarget(
|
|
15
|
+
* ref("cdn", (r: DistributionBuilderResult) => r.distribution),
|
|
16
|
+
* ));
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function cloudfrontAliasTarget(distribution) {
|
|
20
|
+
return isRef(distribution)
|
|
21
|
+
? distribution.map((d) => RecordTarget.fromAlias(new CloudFrontTarget(d)))
|
|
22
|
+
: RecordTarget.fromAlias(new CloudFrontTarget(distribution));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Builds an alias {@link RecordTarget} for an API Gateway REST API that has a
|
|
26
|
+
* custom domain name configured via {@link RestApiBase}. Accepts a
|
|
27
|
+
* {@link Resolvable}.
|
|
28
|
+
*/
|
|
29
|
+
export function apiGatewayAliasTarget(api) {
|
|
30
|
+
return isRef(api)
|
|
31
|
+
? api.map((a) => RecordTarget.fromAlias(new ApiGateway(a)))
|
|
32
|
+
: RecordTarget.fromAlias(new ApiGateway(api));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Builds an alias {@link RecordTarget} for an API Gateway custom domain name
|
|
36
|
+
* (`apigateway.DomainName`). Use this when you manage the domain name resource
|
|
37
|
+
* separately from the REST API (e.g. to share a custom domain across multiple
|
|
38
|
+
* APIs). Accepts a {@link Resolvable}.
|
|
39
|
+
*/
|
|
40
|
+
export function apiGatewayDomainAliasTarget(domain) {
|
|
41
|
+
return isRef(domain)
|
|
42
|
+
? domain.map((d) => RecordTarget.fromAlias(new ApiGatewayDomain(d)))
|
|
43
|
+
: RecordTarget.fromAlias(new ApiGatewayDomain(domain));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=alias-targets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alias-targets.js","sourceRoot":"","sources":["../src/alias-targets.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACjG,OAAO,EAAE,KAAK,EAAmB,MAAM,oBAAoB,CAAC;AAE5D;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,qBAAqB,CACnC,YAAuC;IAEvC,OAAO,KAAK,CAAC,YAAY,CAAC;QACxB,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAA4B;IAChE,OAAO,KAAK,CAAC,GAAG,CAAC;QACf,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,MAA+B;IAE/B,OAAO,KAAK,CAAC,MAAM,CAAC;QAClB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CnameRecord, type CnameRecordProps, type IHostedZone } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import { type IConstruct } from "constructs";
|
|
3
|
+
import { type IBuilder, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
4
|
+
/**
|
|
5
|
+
* Configuration properties for the Route53 CNAME record builder.
|
|
6
|
+
*
|
|
7
|
+
* Extends the CDK {@link CnameRecordProps} but replaces `zone` with a
|
|
8
|
+
* {@link Resolvable} so it can be wired from composed components.
|
|
9
|
+
*/
|
|
10
|
+
export interface CnameRecordBuilderProps extends Omit<CnameRecordProps, "zone"> {
|
|
11
|
+
/** The hosted zone in which to create the record. */
|
|
12
|
+
zone?: Resolvable<IHostedZone>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The build output of an {@link ICnameRecordBuilder}.
|
|
16
|
+
*/
|
|
17
|
+
export interface CnameRecordBuilderResult {
|
|
18
|
+
/** The Route53 CNAME record construct created by the builder. */
|
|
19
|
+
record: CnameRecord;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A fluent builder for configuring and creating a Route53 CNAME record.
|
|
23
|
+
*
|
|
24
|
+
* Prefer {@link createARecordBuilder | A / AAAA alias records} when pointing
|
|
25
|
+
* at AWS resources — alias records are free, resolve in one hop, and can be
|
|
26
|
+
* used at the apex. Use CNAME for non-AWS targets or for sub-domain
|
|
27
|
+
* redirections where an alias is not available.
|
|
28
|
+
*/
|
|
29
|
+
export type ICnameRecordBuilder = IBuilder<CnameRecordBuilderProps, CnameRecordBuilder>;
|
|
30
|
+
declare class CnameRecordBuilder implements Lifecycle<CnameRecordBuilderResult> {
|
|
31
|
+
props: Partial<CnameRecordBuilderProps>;
|
|
32
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): CnameRecordBuilderResult;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new {@link ICnameRecordBuilder} for configuring a Route53 CNAME
|
|
36
|
+
* record.
|
|
37
|
+
*
|
|
38
|
+
* @returns A fluent builder for a Route53 CNAME record.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createCnameRecordBuilder(): ICnameRecordBuilder;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=cname-record-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cname-record-builder.d.ts","sourceRoot":"","sources":["../src/cname-record-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,SAAS,EAEd,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAG5B;;;;;GAKG;AACH,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAC7E,qDAAqD;IACrD,IAAI,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,iEAAiE;IACjE,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,uBAAuB,EAAE,kBAAkB,CAAC,CAAC;AAExF,cAAM,kBAAmB,YAAW,SAAS,CAAC,wBAAwB,CAAC;IACrE,KAAK,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAM;IAE7C,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,wBAAwB;CAgCjG;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,IAAI,mBAAmB,CAE9D"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CnameRecord } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import { Builder, resolve, } from "@composurecdk/core";
|
|
3
|
+
import { CNAME_RECORD_DEFAULTS } from "./defaults.js";
|
|
4
|
+
class CnameRecordBuilder {
|
|
5
|
+
props = {};
|
|
6
|
+
build(scope, id, context) {
|
|
7
|
+
const { zone, domainName, recordName, ...rest } = this.props;
|
|
8
|
+
if (!zone) {
|
|
9
|
+
throw new Error(`CnameRecordBuilder "${id}" requires a zone. Call .zone() with an IHostedZone.`);
|
|
10
|
+
}
|
|
11
|
+
if (!domainName) {
|
|
12
|
+
throw new Error(`CnameRecordBuilder "${id}" requires a domainName. ` +
|
|
13
|
+
`Call .domainName() with the target host (what the CNAME points to).`);
|
|
14
|
+
}
|
|
15
|
+
if (!recordName) {
|
|
16
|
+
throw new Error(`CnameRecordBuilder "${id}" requires a recordName. ` +
|
|
17
|
+
`Call .recordName() with the subdomain — CNAME records cannot be at the zone apex.`);
|
|
18
|
+
}
|
|
19
|
+
const resolvedContext = context ?? {};
|
|
20
|
+
const mergedProps = {
|
|
21
|
+
...CNAME_RECORD_DEFAULTS,
|
|
22
|
+
...rest,
|
|
23
|
+
domainName,
|
|
24
|
+
recordName,
|
|
25
|
+
zone: resolve(zone, resolvedContext),
|
|
26
|
+
};
|
|
27
|
+
const record = new CnameRecord(scope, id, mergedProps);
|
|
28
|
+
return { record };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new {@link ICnameRecordBuilder} for configuring a Route53 CNAME
|
|
33
|
+
* record.
|
|
34
|
+
*
|
|
35
|
+
* @returns A fluent builder for a Route53 CNAME record.
|
|
36
|
+
*/
|
|
37
|
+
export function createCnameRecordBuilder() {
|
|
38
|
+
return Builder(CnameRecordBuilder);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=cname-record-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cname-record-builder.js","sourceRoot":"","sources":["../src/cname-record-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA2C,MAAM,yBAAyB,CAAC;AAE/F,OAAO,EACL,OAAO,EAGP,OAAO,GAER,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AA+BtD,MAAM,kBAAkB;IACtB,KAAK,GAAqC,EAAE,CAAC;IAE7C,KAAK,CAAC,KAAiB,EAAE,EAAU,EAAE,OAAgC;QACnE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7D,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CACb,uBAAuB,EAAE,sDAAsD,CAChF,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CACb,uBAAuB,EAAE,2BAA2B;gBAClD,qEAAqE,CACxE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CACb,uBAAuB,EAAE,2BAA2B;gBAClD,mFAAmF,CACtF,CAAC;QACJ,CAAC;QAED,MAAM,eAAe,GAAG,OAAO,IAAI,EAAE,CAAC;QACtC,MAAM,WAAW,GAAG;YAClB,GAAG,qBAAqB;YACxB,GAAG,IAAI;YACP,UAAU;YACV,UAAU;YACV,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC;SACjB,CAAC;QAEtB,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;QACvD,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,OAAO,CAA8C,kBAAkB,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { HostedZoneBuilderProps } from "./hosted-zone-builder.js";
|
|
2
|
+
import type { ARecordBuilderProps } from "./a-record-builder.js";
|
|
3
|
+
import type { AaaaRecordBuilderProps } from "./aaaa-record-builder.js";
|
|
4
|
+
import type { CnameRecordBuilderProps } from "./cname-record-builder.js";
|
|
5
|
+
import type { TxtRecordBuilderProps } from "./txt-record-builder.js";
|
|
6
|
+
/**
|
|
7
|
+
* Secure, AWS-recommended defaults applied to every public hosted zone built
|
|
8
|
+
* with {@link createHostedZoneBuilder}. Each property can be individually
|
|
9
|
+
* overridden via the builder's fluent API.
|
|
10
|
+
*
|
|
11
|
+
* Query logging is not enabled by default: Route53 query logs must be written
|
|
12
|
+
* to a CloudWatch log group in `us-east-1` with a resource policy granting
|
|
13
|
+
* `route53.amazonaws.com` write access. Opt in explicitly by calling
|
|
14
|
+
* `.queryLogsLogGroupArn(...)` with a pre-configured log group.
|
|
15
|
+
*/
|
|
16
|
+
export declare const HOSTED_ZONE_DEFAULTS: Partial<HostedZoneBuilderProps>;
|
|
17
|
+
/**
|
|
18
|
+
* Defaults for {@link createARecordBuilder}. Overridable via the fluent API.
|
|
19
|
+
* The builder skips the `ttl` default for alias targets — AWS ignores TTL on
|
|
20
|
+
* alias records and CDK emits a warning when one is set.
|
|
21
|
+
*/
|
|
22
|
+
export declare const A_RECORD_DEFAULTS: Partial<ARecordBuilderProps>;
|
|
23
|
+
/**
|
|
24
|
+
* Defaults for {@link createAaaaRecordBuilder}. Overridable via the fluent API.
|
|
25
|
+
* Same alias-target caveat as {@link A_RECORD_DEFAULTS}.
|
|
26
|
+
*/
|
|
27
|
+
export declare const AAAA_RECORD_DEFAULTS: Partial<AaaaRecordBuilderProps>;
|
|
28
|
+
/**
|
|
29
|
+
* Defaults for {@link createCnameRecordBuilder}. Overridable via the fluent API.
|
|
30
|
+
*/
|
|
31
|
+
export declare const CNAME_RECORD_DEFAULTS: Partial<CnameRecordBuilderProps>;
|
|
32
|
+
/**
|
|
33
|
+
* Defaults for {@link createTxtRecordBuilder}. Overridable via the fluent API.
|
|
34
|
+
*/
|
|
35
|
+
export declare const TXT_RECORD_DEFAULTS: Partial<TxtRecordBuilderProps>;
|
|
36
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAErE;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC,sBAAsB,CAMhE,CAAC;AAaF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAAO,CAAC,mBAAmB,CAE1D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC,sBAAsB,CAEhE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,OAAO,CAAC,uBAAuB,CAElE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,qBAAqB,CAE9D,CAAC"}
|
package/dist/defaults.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Duration } from "aws-cdk-lib";
|
|
2
|
+
/**
|
|
3
|
+
* Secure, AWS-recommended defaults applied to every public hosted zone built
|
|
4
|
+
* with {@link createHostedZoneBuilder}. Each property can be individually
|
|
5
|
+
* overridden via the builder's fluent API.
|
|
6
|
+
*
|
|
7
|
+
* Query logging is not enabled by default: Route53 query logs must be written
|
|
8
|
+
* to a CloudWatch log group in `us-east-1` with a resource policy granting
|
|
9
|
+
* `route53.amazonaws.com` write access. Opt in explicitly by calling
|
|
10
|
+
* `.queryLogsLogGroupArn(...)` with a pre-configured log group.
|
|
11
|
+
*/
|
|
12
|
+
export const HOSTED_ZONE_DEFAULTS = {
|
|
13
|
+
/**
|
|
14
|
+
* Add a trailing dot to the zone name so the apex is an unambiguous
|
|
15
|
+
* fully-qualified domain. Matches the CDK default and RFC 1035.
|
|
16
|
+
*/
|
|
17
|
+
addTrailingDot: true,
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Default TTL applied to records built by this package when no TTL is set.
|
|
21
|
+
*
|
|
22
|
+
* Five minutes balances propagation latency against downstream DNS cache
|
|
23
|
+
* churn. For alias records pointing at dynamic AWS resources (CloudFront,
|
|
24
|
+
* ALB), this matches AWS guidance.
|
|
25
|
+
*
|
|
26
|
+
* @see https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-cloudfront-distribution.html
|
|
27
|
+
*/
|
|
28
|
+
const DEFAULT_RECORD_TTL = Duration.minutes(5);
|
|
29
|
+
/**
|
|
30
|
+
* Defaults for {@link createARecordBuilder}. Overridable via the fluent API.
|
|
31
|
+
* The builder skips the `ttl` default for alias targets — AWS ignores TTL on
|
|
32
|
+
* alias records and CDK emits a warning when one is set.
|
|
33
|
+
*/
|
|
34
|
+
export const A_RECORD_DEFAULTS = {
|
|
35
|
+
ttl: DEFAULT_RECORD_TTL,
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Defaults for {@link createAaaaRecordBuilder}. Overridable via the fluent API.
|
|
39
|
+
* Same alias-target caveat as {@link A_RECORD_DEFAULTS}.
|
|
40
|
+
*/
|
|
41
|
+
export const AAAA_RECORD_DEFAULTS = {
|
|
42
|
+
ttl: DEFAULT_RECORD_TTL,
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Defaults for {@link createCnameRecordBuilder}. Overridable via the fluent API.
|
|
46
|
+
*/
|
|
47
|
+
export const CNAME_RECORD_DEFAULTS = {
|
|
48
|
+
ttl: DEFAULT_RECORD_TTL,
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Defaults for {@link createTxtRecordBuilder}. Overridable via the fluent API.
|
|
52
|
+
*/
|
|
53
|
+
export const TXT_RECORD_DEFAULTS = {
|
|
54
|
+
ttl: DEFAULT_RECORD_TTL,
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAOvC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAoC;IACnE;;;OAGG;IACH,cAAc,EAAE,IAAI;CACrB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,kBAAkB,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAE/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAiC;IAC7D,GAAG,EAAE,kBAAkB;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAoC;IACnE,GAAG,EAAE,kBAAkB;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAqC;IACrE,GAAG,EAAE,kBAAkB;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAmC;IACjE,GAAG,EAAE,kBAAkB;CACxB,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { PublicHostedZone, type PublicHostedZoneProps } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import { type IConstruct } from "constructs";
|
|
3
|
+
import { type IBuilder, type Lifecycle } from "@composurecdk/core";
|
|
4
|
+
/**
|
|
5
|
+
* Configuration properties for the Route53 public hosted zone builder.
|
|
6
|
+
*
|
|
7
|
+
* Aliases the CDK {@link PublicHostedZoneProps} so every zone property is
|
|
8
|
+
* available as a fluent setter on the builder. No additional builder-specific
|
|
9
|
+
* options are defined today — query logging requires a pre-configured log
|
|
10
|
+
* group (see {@link PublicHostedZoneProps.queryLogsLogGroupArn | queryLogsLogGroupArn})
|
|
11
|
+
* which the user supplies directly.
|
|
12
|
+
*/
|
|
13
|
+
export type HostedZoneBuilderProps = PublicHostedZoneProps;
|
|
14
|
+
/**
|
|
15
|
+
* The build output of an {@link IHostedZoneBuilder}. Contains the CDK
|
|
16
|
+
* constructs created during {@link Lifecycle.build}, keyed by role.
|
|
17
|
+
*/
|
|
18
|
+
export interface HostedZoneBuilderResult {
|
|
19
|
+
/** The Route53 public hosted zone construct created by the builder. */
|
|
20
|
+
hostedZone: PublicHostedZone;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A fluent builder for configuring and creating a Route53 public hosted zone.
|
|
24
|
+
*
|
|
25
|
+
* Each configuration property from the CDK {@link PublicHostedZoneProps} is
|
|
26
|
+
* exposed as an overloaded method: call with a value to set it (returns the
|
|
27
|
+
* builder for chaining), or call with no arguments to read the current value.
|
|
28
|
+
*
|
|
29
|
+
* The builder implements {@link Lifecycle}, so it can be used directly as a
|
|
30
|
+
* component in a {@link compose | composed system}. When built, it creates a
|
|
31
|
+
* public hosted zone with the configured properties and returns a
|
|
32
|
+
* {@link HostedZoneBuilderResult}.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const zone = createHostedZoneBuilder()
|
|
37
|
+
* .zoneName("example.com")
|
|
38
|
+
* .comment("Primary customer-facing domain");
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export type IHostedZoneBuilder = IBuilder<HostedZoneBuilderProps, HostedZoneBuilder>;
|
|
42
|
+
declare class HostedZoneBuilder implements Lifecycle<HostedZoneBuilderResult> {
|
|
43
|
+
props: Partial<HostedZoneBuilderProps>;
|
|
44
|
+
build(scope: IConstruct, id: string): HostedZoneBuilderResult;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new {@link IHostedZoneBuilder} for configuring a Route53 public
|
|
48
|
+
* hosted zone.
|
|
49
|
+
*
|
|
50
|
+
* This is the entry point for defining a public hosted zone component. The
|
|
51
|
+
* returned builder exposes every {@link HostedZoneBuilderProps} property as a
|
|
52
|
+
* fluent setter/getter and implements {@link Lifecycle} for use with
|
|
53
|
+
* {@link compose}.
|
|
54
|
+
*
|
|
55
|
+
* @returns A fluent builder for a Route53 public hosted zone.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const zone = createHostedZoneBuilder().zoneName("example.com");
|
|
60
|
+
*
|
|
61
|
+
* // Use standalone:
|
|
62
|
+
* const result = zone.build(stack, "SiteZone");
|
|
63
|
+
*
|
|
64
|
+
* // Or compose into a system:
|
|
65
|
+
* const system = compose(
|
|
66
|
+
* { zone, cert: createCertificateBuilder()
|
|
67
|
+
* .domainName("example.com")
|
|
68
|
+
* .validationZone(ref("zone", (r: HostedZoneBuilderResult) => r.hostedZone)) },
|
|
69
|
+
* { zone: [], cert: ["zone"] },
|
|
70
|
+
* );
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function createHostedZoneBuilder(): IHostedZoneBuilder;
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=hosted-zone-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-zone-builder.d.ts","sourceRoot":"","sources":["../src/hosted-zone-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAW,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG5E;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AAE3D;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,uEAAuE;IACvE,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,sBAAsB,EAAE,iBAAiB,CAAC,CAAC;AAErF,cAAM,iBAAkB,YAAW,SAAS,CAAC,uBAAuB,CAAC;IACnE,KAAK,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAM;IAE5C,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,uBAAuB;CAiB9D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,uBAAuB,IAAI,kBAAkB,CAE5D"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { PublicHostedZone } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import { Builder } from "@composurecdk/core";
|
|
3
|
+
import { HOSTED_ZONE_DEFAULTS } from "./defaults.js";
|
|
4
|
+
class HostedZoneBuilder {
|
|
5
|
+
props = {};
|
|
6
|
+
build(scope, id) {
|
|
7
|
+
if (!this.props.zoneName) {
|
|
8
|
+
throw new Error(`HostedZoneBuilder "${id}" requires a zoneName. ` +
|
|
9
|
+
`Call .zoneName() with a fully-qualified domain.`);
|
|
10
|
+
}
|
|
11
|
+
const mergedProps = {
|
|
12
|
+
...HOSTED_ZONE_DEFAULTS,
|
|
13
|
+
...this.props,
|
|
14
|
+
};
|
|
15
|
+
const hostedZone = new PublicHostedZone(scope, id, mergedProps);
|
|
16
|
+
return { hostedZone };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new {@link IHostedZoneBuilder} for configuring a Route53 public
|
|
21
|
+
* hosted zone.
|
|
22
|
+
*
|
|
23
|
+
* This is the entry point for defining a public hosted zone component. The
|
|
24
|
+
* returned builder exposes every {@link HostedZoneBuilderProps} property as a
|
|
25
|
+
* fluent setter/getter and implements {@link Lifecycle} for use with
|
|
26
|
+
* {@link compose}.
|
|
27
|
+
*
|
|
28
|
+
* @returns A fluent builder for a Route53 public hosted zone.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const zone = createHostedZoneBuilder().zoneName("example.com");
|
|
33
|
+
*
|
|
34
|
+
* // Use standalone:
|
|
35
|
+
* const result = zone.build(stack, "SiteZone");
|
|
36
|
+
*
|
|
37
|
+
* // Or compose into a system:
|
|
38
|
+
* const system = compose(
|
|
39
|
+
* { zone, cert: createCertificateBuilder()
|
|
40
|
+
* .domainName("example.com")
|
|
41
|
+
* .validationZone(ref("zone", (r: HostedZoneBuilderResult) => r.hostedZone)) },
|
|
42
|
+
* { zone: [], cert: ["zone"] },
|
|
43
|
+
* );
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export function createHostedZoneBuilder() {
|
|
47
|
+
return Builder(HostedZoneBuilder);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=hosted-zone-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-zone-builder.js","sourceRoot":"","sources":["../src/hosted-zone-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA8B,MAAM,yBAAyB,CAAC;AAEvF,OAAO,EAAE,OAAO,EAAiC,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AA2CrD,MAAM,iBAAiB;IACrB,KAAK,GAAoC,EAAE,CAAC;IAE5C,KAAK,CAAC,KAAiB,EAAE,EAAU;QACjC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,sBAAsB,EAAE,yBAAyB;gBAC/C,iDAAiD,CACpD,CAAC;QACJ,CAAC;QAED,MAAM,WAAW,GAAG;YAClB,GAAG,oBAAoB;YACvB,GAAG,IAAI,CAAC,KAAK;SACW,CAAC;QAE3B,MAAM,UAAU,GAAG,IAAI,gBAAgB,CAAC,KAAK,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;QAEhE,OAAO,EAAE,UAAU,EAAE,CAAC;IACxB,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,OAAO,CAA4C,iBAAiB,CAAC,CAAC;AAC/E,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createHostedZoneBuilder, type HostedZoneBuilderResult, type IHostedZoneBuilder, } from "./hosted-zone-builder.js";
|
|
2
|
+
export { createARecordBuilder, type ARecordBuilderResult, type IARecordBuilder, } from "./a-record-builder.js";
|
|
3
|
+
export { createAaaaRecordBuilder, type AaaaRecordBuilderResult, type IAaaaRecordBuilder, } from "./aaaa-record-builder.js";
|
|
4
|
+
export { createCnameRecordBuilder, type CnameRecordBuilderResult, type ICnameRecordBuilder, } from "./cname-record-builder.js";
|
|
5
|
+
export { createTxtRecordBuilder, type TxtRecordBuilderResult, type ITxtRecordBuilder, } from "./txt-record-builder.js";
|
|
6
|
+
export { cloudfrontAliasTarget, apiGatewayAliasTarget, apiGatewayDomainAliasTarget, } from "./alias-targets.js";
|
|
7
|
+
export { HOSTED_ZONE_DEFAULTS, A_RECORD_DEFAULTS, AAAA_RECORD_DEFAULTS, CNAME_RECORD_DEFAULTS, TXT_RECORD_DEFAULTS, } from "./defaults.js";
|
|
8
|
+
//# 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,uBAAuB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,oBAAoB,EACpB,KAAK,oBAAoB,EACzB,KAAK,eAAe,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uBAAuB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,GACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createHostedZoneBuilder, } from "./hosted-zone-builder.js";
|
|
2
|
+
export { createARecordBuilder, } from "./a-record-builder.js";
|
|
3
|
+
export { createAaaaRecordBuilder, } from "./aaaa-record-builder.js";
|
|
4
|
+
export { createCnameRecordBuilder, } from "./cname-record-builder.js";
|
|
5
|
+
export { createTxtRecordBuilder, } from "./txt-record-builder.js";
|
|
6
|
+
export { cloudfrontAliasTarget, apiGatewayAliasTarget, apiGatewayDomainAliasTarget, } from "./alias-targets.js";
|
|
7
|
+
export { HOSTED_ZONE_DEFAULTS, A_RECORD_DEFAULTS, AAAA_RECORD_DEFAULTS, CNAME_RECORD_DEFAULTS, TXT_RECORD_DEFAULTS, } from "./defaults.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAGxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,oBAAoB,GAGrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uBAAuB,GAGxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,GAGzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,sBAAsB,GAGvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TxtRecord, type TxtRecordProps, type IHostedZone } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import { type IConstruct } from "constructs";
|
|
3
|
+
import { type IBuilder, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
4
|
+
/**
|
|
5
|
+
* Configuration properties for the Route53 TXT record builder.
|
|
6
|
+
*
|
|
7
|
+
* Extends the CDK {@link TxtRecordProps} but replaces `zone` with a
|
|
8
|
+
* {@link Resolvable} so it can be wired from composed components.
|
|
9
|
+
*/
|
|
10
|
+
export interface TxtRecordBuilderProps extends Omit<TxtRecordProps, "zone"> {
|
|
11
|
+
/** The hosted zone in which to create the record. */
|
|
12
|
+
zone?: Resolvable<IHostedZone>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The build output of an {@link ITxtRecordBuilder}.
|
|
16
|
+
*/
|
|
17
|
+
export interface TxtRecordBuilderResult {
|
|
18
|
+
/** The Route53 TXT record construct created by the builder. */
|
|
19
|
+
record: TxtRecord;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A fluent builder for configuring and creating a Route53 TXT record.
|
|
23
|
+
*
|
|
24
|
+
* Commonly used for SPF, DKIM, DMARC, and domain-verification tokens.
|
|
25
|
+
*/
|
|
26
|
+
export type ITxtRecordBuilder = IBuilder<TxtRecordBuilderProps, TxtRecordBuilder>;
|
|
27
|
+
declare class TxtRecordBuilder implements Lifecycle<TxtRecordBuilderResult> {
|
|
28
|
+
props: Partial<TxtRecordBuilderProps>;
|
|
29
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): TxtRecordBuilderResult;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new {@link ITxtRecordBuilder} for configuring a Route53 TXT record.
|
|
33
|
+
*
|
|
34
|
+
* @returns A fluent builder for a Route53 TXT record.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createTxtRecordBuilder(): ITxtRecordBuilder;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=txt-record-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"txt-record-builder.d.ts","sourceRoot":"","sources":["../src/txt-record-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3F,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,SAAS,EAEd,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAG5B;;;;;GAKG;AACH,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC;IACzE,qDAAqD;IACrD,IAAI,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,+DAA+D;IAC/D,MAAM,EAAE,SAAS,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,CAAC;AAElF,cAAM,gBAAiB,YAAW,SAAS,CAAC,sBAAsB,CAAC;IACjE,KAAK,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAM;IAE3C,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,sBAAsB;CAyB/F;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,iBAAiB,CAE1D"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TxtRecord } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import { Builder, resolve, } from "@composurecdk/core";
|
|
3
|
+
import { TXT_RECORD_DEFAULTS } from "./defaults.js";
|
|
4
|
+
class TxtRecordBuilder {
|
|
5
|
+
props = {};
|
|
6
|
+
build(scope, id, context) {
|
|
7
|
+
const { zone, values, ...rest } = this.props;
|
|
8
|
+
if (!zone) {
|
|
9
|
+
throw new Error(`TxtRecordBuilder "${id}" requires a zone. Call .zone() with an IHostedZone.`);
|
|
10
|
+
}
|
|
11
|
+
if (!values || values.length === 0) {
|
|
12
|
+
throw new Error(`TxtRecordBuilder "${id}" requires non-empty values. ` +
|
|
13
|
+
`Call .values() with one or more TXT record strings.`);
|
|
14
|
+
}
|
|
15
|
+
const resolvedContext = context ?? {};
|
|
16
|
+
const mergedProps = {
|
|
17
|
+
...TXT_RECORD_DEFAULTS,
|
|
18
|
+
...rest,
|
|
19
|
+
values,
|
|
20
|
+
zone: resolve(zone, resolvedContext),
|
|
21
|
+
};
|
|
22
|
+
const record = new TxtRecord(scope, id, mergedProps);
|
|
23
|
+
return { record };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new {@link ITxtRecordBuilder} for configuring a Route53 TXT record.
|
|
28
|
+
*
|
|
29
|
+
* @returns A fluent builder for a Route53 TXT record.
|
|
30
|
+
*/
|
|
31
|
+
export function createTxtRecordBuilder() {
|
|
32
|
+
return Builder(TxtRecordBuilder);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=txt-record-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"txt-record-builder.js","sourceRoot":"","sources":["../src/txt-record-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAyC,MAAM,yBAAyB,CAAC;AAE3F,OAAO,EACL,OAAO,EAGP,OAAO,GAER,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AA4BpD,MAAM,gBAAgB;IACpB,KAAK,GAAmC,EAAE,CAAC;IAE3C,KAAK,CAAC,KAAiB,EAAE,EAAU,EAAE,OAAgC;QACnE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CACb,qBAAqB,EAAE,sDAAsD,CAC9E,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CACb,qBAAqB,EAAE,+BAA+B;gBACpD,qDAAqD,CACxD,CAAC;QACJ,CAAC;QAED,MAAM,eAAe,GAAG,OAAO,IAAI,EAAE,CAAC;QACtC,MAAM,WAAW,GAAG;YAClB,GAAG,mBAAmB;YACtB,GAAG,IAAI;YACP,MAAM;YACN,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC;SACnB,CAAC;QAEpB,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,KAAK,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;QACrD,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,OAAO,CAA0C,gBAAgB,CAAC,CAAC;AAC5E,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@composurecdk/route53",
|
|
3
|
+
"version": "0.3.3",
|
|
4
|
+
"description": "Composable Route53 hosted zone and record builders with well-architected defaults",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/laazyj/composureCDK",
|
|
8
|
+
"directory": "packages/route53"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"clean": "rm -rf dist",
|
|
25
|
+
"build": "tsc -p tsconfig.build.json",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"test": "vitest run --passWithNoTests",
|
|
28
|
+
"test:watch": "vitest"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [],
|
|
31
|
+
"author": "Jason Duffett (https://github.com/laazyj)",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"type": "module",
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@composurecdk/core": "^0.3.0",
|
|
39
|
+
"aws-cdk-lib": "^2.0.0",
|
|
40
|
+
"constructs": "^10.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^25.6.0",
|
|
44
|
+
"aws-cdk-lib": "^2.250.0",
|
|
45
|
+
"constructs": "^10.6.0",
|
|
46
|
+
"typescript": "^6.0.3",
|
|
47
|
+
"vitest": "^4.1.4"
|
|
48
|
+
}
|
|
49
|
+
}
|