@jaggr2/cdk-cf-dns 0.1.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/API.md +411 -0
- package/README.md +194 -0
- package/lib/certificate.d.ts +41 -0
- package/lib/certificate.js +83 -0
- package/lib/certificate.js.map +1 -0
- package/lib/handler/acm.d.ts +12 -0
- package/lib/handler/acm.js +131 -0
- package/lib/handler/acm.js.map +1 -0
- package/lib/handler/cloudflare.d.ts +133 -0
- package/lib/handler/cloudflare.js +264 -0
- package/lib/handler/cloudflare.js.map +1 -0
- package/lib/handler/index.d.ts +11 -0
- package/lib/handler/index.js +114 -0
- package/lib/handler/index.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -0
- package/lib/provider.d.ts +75 -0
- package/lib/provider.js +234 -0
- package/lib/provider.js.map +1 -0
- package/lib/record.d.ts +225 -0
- package/lib/record.js +297 -0
- package/lib/record.js.map +1 -0
- package/lib/zone.d.ts +72 -0
- package/lib/zone.js +90 -0
- package/lib/zone.js.map +1 -0
- package/package.json +61 -0
- package/src/certificate.ts +74 -0
- package/src/handler/acm.ts +160 -0
- package/src/handler/cloudflare.ts +305 -0
- package/src/handler/deps.lock.json +3 -0
- package/src/handler/index.ts +145 -0
- package/src/index.ts +4 -0
- package/src/provider.ts +223 -0
- package/src/record.ts +433 -0
- package/src/zone.ts +115 -0
package/lib/record.d.ts
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { Duration, RemovalPolicy } from 'aws-cdk-lib';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
|
+
import { ICloudflareZone } from './zone';
|
|
4
|
+
/**
|
|
5
|
+
* The DNS record types supported by this library.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum CloudflareRecordType {
|
|
8
|
+
/** An IPv4 address record. */
|
|
9
|
+
A = "A",
|
|
10
|
+
/** An IPv6 address record. */
|
|
11
|
+
AAAA = "AAAA",
|
|
12
|
+
/** A canonical name record. */
|
|
13
|
+
CNAME = "CNAME",
|
|
14
|
+
/** A text record. */
|
|
15
|
+
TXT = "TXT",
|
|
16
|
+
/** A mail exchanger record. */
|
|
17
|
+
MX = "MX",
|
|
18
|
+
/** A name server record. */
|
|
19
|
+
NS = "NS",
|
|
20
|
+
/** A service locator record. */
|
|
21
|
+
SRV = "SRV",
|
|
22
|
+
/** A certification authority authorization record. */
|
|
23
|
+
CAA = "CAA",
|
|
24
|
+
/** A pointer record. */
|
|
25
|
+
PTR = "PTR",
|
|
26
|
+
/** A uniform resource identifier record. */
|
|
27
|
+
URI = "URI"
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* TTL helpers for Cloudflare records.
|
|
31
|
+
*/
|
|
32
|
+
export declare class CloudflareTtl {
|
|
33
|
+
/**
|
|
34
|
+
* Cloudflare's automatic TTL (a value of `1` on the wire).
|
|
35
|
+
*/
|
|
36
|
+
static readonly AUTO: Duration;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Properties for a Cloudflare DNS record.
|
|
40
|
+
*/
|
|
41
|
+
export interface CloudflareRecordProps {
|
|
42
|
+
/**
|
|
43
|
+
* The Cloudflare zone the record belongs to.
|
|
44
|
+
*/
|
|
45
|
+
readonly zone: ICloudflareZone;
|
|
46
|
+
/**
|
|
47
|
+
* Record name. If it does not end in the zone name and `zone.zoneName` is set,
|
|
48
|
+
* it is treated as relative and the zone name is appended.
|
|
49
|
+
* Use `'@'` or omit for the zone apex.
|
|
50
|
+
*
|
|
51
|
+
* @default - the zone apex
|
|
52
|
+
*/
|
|
53
|
+
readonly recordName?: string;
|
|
54
|
+
/**
|
|
55
|
+
* The record type.
|
|
56
|
+
*/
|
|
57
|
+
readonly type: CloudflareRecordType;
|
|
58
|
+
/**
|
|
59
|
+
* Record value. Mutually exclusive with `data`.
|
|
60
|
+
*/
|
|
61
|
+
readonly content?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Structured value for SRV/CAA/URI records. Mutually exclusive with `content`.
|
|
64
|
+
*/
|
|
65
|
+
readonly data?: Record<string, unknown>;
|
|
66
|
+
/**
|
|
67
|
+
* The time-to-live for the record.
|
|
68
|
+
*
|
|
69
|
+
* @default Duration.minutes(5) — pass `CloudflareTtl.AUTO` for Cloudflare's automatic TTL (1)
|
|
70
|
+
*/
|
|
71
|
+
readonly ttl?: Duration;
|
|
72
|
+
/**
|
|
73
|
+
* Whether to proxy the record through Cloudflare. Only valid for A, AAAA and CNAME.
|
|
74
|
+
*
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
readonly proxied?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Record priority. Required for MX, SRV and URI.
|
|
80
|
+
*/
|
|
81
|
+
readonly priority?: number;
|
|
82
|
+
/**
|
|
83
|
+
* A free-form comment attached to the record.
|
|
84
|
+
*
|
|
85
|
+
* @default - no comment
|
|
86
|
+
*/
|
|
87
|
+
readonly comment?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Tags attached to the record.
|
|
90
|
+
*
|
|
91
|
+
* @default - no tags
|
|
92
|
+
*/
|
|
93
|
+
readonly tags?: string[];
|
|
94
|
+
/**
|
|
95
|
+
* If a record with the same name+type already exists in Cloudflare, adopt and
|
|
96
|
+
* manage it instead of failing the deployment.
|
|
97
|
+
*
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
100
|
+
readonly adoptExisting?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* If RETAIN, the record is left in Cloudflare when the stack resource is deleted.
|
|
103
|
+
*
|
|
104
|
+
* @default RemovalPolicy.DESTROY
|
|
105
|
+
*/
|
|
106
|
+
readonly removalPolicy?: RemovalPolicy;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A Cloudflare DNS record managed as a CloudFormation resource.
|
|
110
|
+
*
|
|
111
|
+
* The construct synthesises a `Custom::CloudflareDnsRecord` custom resource whose
|
|
112
|
+
* Lambda handler calls the Cloudflare API. The API token is resolved at runtime
|
|
113
|
+
* from Secrets Manager; only the secret ARN ever appears in the template.
|
|
114
|
+
*/
|
|
115
|
+
export declare class CloudflareRecord extends Construct {
|
|
116
|
+
/**
|
|
117
|
+
* Cloudflare's record ID, from `GetAtt`. This is the value you can use to
|
|
118
|
+
* locate the record in the Cloudflare dashboard.
|
|
119
|
+
*/
|
|
120
|
+
readonly recordId: string;
|
|
121
|
+
/**
|
|
122
|
+
* The fully-qualified name actually written to Cloudflare (e.g. `app.example.com`).
|
|
123
|
+
*/
|
|
124
|
+
readonly domainName: string;
|
|
125
|
+
/**
|
|
126
|
+
* The underlying custom resource.
|
|
127
|
+
*/
|
|
128
|
+
private readonly resource;
|
|
129
|
+
constructor(scope: Construct, id: string, props: CloudflareRecordProps);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Resolves a relative record name against the zone name, matching the
|
|
133
|
+
* `aws-cdk-lib/aws-route53` ergonomics.
|
|
134
|
+
*
|
|
135
|
+
* - `undefined` or `'@'` resolves to the zone apex.
|
|
136
|
+
* - A name that already ends in the zone name is used verbatim.
|
|
137
|
+
* - Anything else is treated as relative and the zone name is appended.
|
|
138
|
+
*/
|
|
139
|
+
export declare function resolveRecordName(recordName: string | undefined, zoneName: string | undefined): string;
|
|
140
|
+
/**
|
|
141
|
+
* Properties for an A record.
|
|
142
|
+
*/
|
|
143
|
+
export interface CloudflareARecordProps extends Omit<CloudflareRecordProps, 'type' | 'data' | 'priority'> {
|
|
144
|
+
/** The IPv4 address. */
|
|
145
|
+
readonly content: string;
|
|
146
|
+
/** Whether to proxy the record through Cloudflare. @default false */
|
|
147
|
+
readonly proxied?: boolean;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* An A record.
|
|
151
|
+
*/
|
|
152
|
+
export declare class CloudflareARecord extends CloudflareRecord {
|
|
153
|
+
constructor(scope: Construct, id: string, props: CloudflareARecordProps);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Properties for an AAAA record.
|
|
157
|
+
*/
|
|
158
|
+
export interface CloudflareAaaaRecordProps extends Omit<CloudflareRecordProps, 'type' | 'data' | 'priority'> {
|
|
159
|
+
/** The IPv6 address. */
|
|
160
|
+
readonly content: string;
|
|
161
|
+
/** Whether to proxy the record through Cloudflare. @default false */
|
|
162
|
+
readonly proxied?: boolean;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* An AAAA record.
|
|
166
|
+
*/
|
|
167
|
+
export declare class CloudflareAaaaRecord extends CloudflareRecord {
|
|
168
|
+
constructor(scope: Construct, id: string, props: CloudflareAaaaRecordProps);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Properties for a CNAME record.
|
|
172
|
+
*/
|
|
173
|
+
export interface CloudflareCnameRecordProps extends Omit<CloudflareRecordProps, 'type' | 'data' | 'priority'> {
|
|
174
|
+
/** The canonical name. */
|
|
175
|
+
readonly content: string;
|
|
176
|
+
/** Whether to proxy the record through Cloudflare. @default false */
|
|
177
|
+
readonly proxied?: boolean;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* A CNAME record.
|
|
181
|
+
*/
|
|
182
|
+
export declare class CloudflareCnameRecord extends CloudflareRecord {
|
|
183
|
+
constructor(scope: Construct, id: string, props: CloudflareCnameRecordProps);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Properties for a TXT record.
|
|
187
|
+
*/
|
|
188
|
+
export interface CloudflareTxtRecordProps extends Omit<CloudflareRecordProps, 'type' | 'data' | 'proxied' | 'priority'> {
|
|
189
|
+
/** The text value. Values longer than 255 characters are automatically chunked. */
|
|
190
|
+
readonly content: string;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* A TXT record.
|
|
194
|
+
*/
|
|
195
|
+
export declare class CloudflareTxtRecord extends CloudflareRecord {
|
|
196
|
+
constructor(scope: Construct, id: string, props: CloudflareTxtRecordProps);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Properties for an MX record.
|
|
200
|
+
*/
|
|
201
|
+
export interface CloudflareMxRecordProps extends Omit<CloudflareRecordProps, 'type' | 'data' | 'proxied'> {
|
|
202
|
+
/** The mail exchanger host. */
|
|
203
|
+
readonly content: string;
|
|
204
|
+
/** The MX priority. */
|
|
205
|
+
readonly priority: number;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* An MX record.
|
|
209
|
+
*/
|
|
210
|
+
export declare class CloudflareMxRecord extends CloudflareRecord {
|
|
211
|
+
constructor(scope: Construct, id: string, props: CloudflareMxRecordProps);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Properties for a CAA record.
|
|
215
|
+
*/
|
|
216
|
+
export interface CloudflareCaaRecordProps extends Omit<CloudflareRecordProps, 'type' | 'data' | 'proxied' | 'priority'> {
|
|
217
|
+
/** The CAA value. */
|
|
218
|
+
readonly content: string;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* A CAA record.
|
|
222
|
+
*/
|
|
223
|
+
export declare class CloudflareCaaRecord extends CloudflareRecord {
|
|
224
|
+
constructor(scope: Construct, id: string, props: CloudflareCaaRecordProps);
|
|
225
|
+
}
|
package/lib/record.js
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.CloudflareCaaRecord = exports.CloudflareMxRecord = exports.CloudflareTxtRecord = exports.CloudflareCnameRecord = exports.CloudflareAaaaRecord = exports.CloudflareARecord = exports.CloudflareRecord = exports.CloudflareTtl = exports.CloudflareRecordType = void 0;
|
|
37
|
+
exports.resolveRecordName = resolveRecordName;
|
|
38
|
+
const cdk = __importStar(require("aws-cdk-lib"));
|
|
39
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
40
|
+
const constructs_1 = require("constructs");
|
|
41
|
+
const provider_1 = require("./provider");
|
|
42
|
+
/**
|
|
43
|
+
* The DNS record types supported by this library.
|
|
44
|
+
*/
|
|
45
|
+
var CloudflareRecordType;
|
|
46
|
+
(function (CloudflareRecordType) {
|
|
47
|
+
/** An IPv4 address record. */
|
|
48
|
+
CloudflareRecordType["A"] = "A";
|
|
49
|
+
/** An IPv6 address record. */
|
|
50
|
+
CloudflareRecordType["AAAA"] = "AAAA";
|
|
51
|
+
/** A canonical name record. */
|
|
52
|
+
CloudflareRecordType["CNAME"] = "CNAME";
|
|
53
|
+
/** A text record. */
|
|
54
|
+
CloudflareRecordType["TXT"] = "TXT";
|
|
55
|
+
/** A mail exchanger record. */
|
|
56
|
+
CloudflareRecordType["MX"] = "MX";
|
|
57
|
+
/** A name server record. */
|
|
58
|
+
CloudflareRecordType["NS"] = "NS";
|
|
59
|
+
/** A service locator record. */
|
|
60
|
+
CloudflareRecordType["SRV"] = "SRV";
|
|
61
|
+
/** A certification authority authorization record. */
|
|
62
|
+
CloudflareRecordType["CAA"] = "CAA";
|
|
63
|
+
/** A pointer record. */
|
|
64
|
+
CloudflareRecordType["PTR"] = "PTR";
|
|
65
|
+
/** A uniform resource identifier record. */
|
|
66
|
+
CloudflareRecordType["URI"] = "URI";
|
|
67
|
+
})(CloudflareRecordType || (exports.CloudflareRecordType = CloudflareRecordType = {}));
|
|
68
|
+
/**
|
|
69
|
+
* TTL helpers for Cloudflare records.
|
|
70
|
+
*/
|
|
71
|
+
class CloudflareTtl {
|
|
72
|
+
/**
|
|
73
|
+
* Cloudflare's automatic TTL (a value of `1` on the wire).
|
|
74
|
+
*/
|
|
75
|
+
static AUTO = aws_cdk_lib_1.Duration.seconds(1);
|
|
76
|
+
}
|
|
77
|
+
exports.CloudflareTtl = CloudflareTtl;
|
|
78
|
+
/**
|
|
79
|
+
* The set of record types that may be proxied through Cloudflare.
|
|
80
|
+
*/
|
|
81
|
+
const PROXIED_TYPES = new Set([CloudflareRecordType.A, CloudflareRecordType.AAAA, CloudflareRecordType.CNAME]);
|
|
82
|
+
/**
|
|
83
|
+
* The set of record types that require a priority.
|
|
84
|
+
*/
|
|
85
|
+
const PRIORITY_TYPES = new Set([CloudflareRecordType.MX, CloudflareRecordType.SRV, CloudflareRecordType.URI]);
|
|
86
|
+
/**
|
|
87
|
+
* The minimum TTL accepted by Cloudflare.
|
|
88
|
+
*/
|
|
89
|
+
const MIN_TTL_SECONDS = 60;
|
|
90
|
+
/**
|
|
91
|
+
* The maximum TTL accepted by Cloudflare.
|
|
92
|
+
*/
|
|
93
|
+
const MAX_TTL_SECONDS = 86400;
|
|
94
|
+
/**
|
|
95
|
+
* A Cloudflare DNS record managed as a CloudFormation resource.
|
|
96
|
+
*
|
|
97
|
+
* The construct synthesises a `Custom::CloudflareDnsRecord` custom resource whose
|
|
98
|
+
* Lambda handler calls the Cloudflare API. The API token is resolved at runtime
|
|
99
|
+
* from Secrets Manager; only the secret ARN ever appears in the template.
|
|
100
|
+
*/
|
|
101
|
+
class CloudflareRecord extends constructs_1.Construct {
|
|
102
|
+
/**
|
|
103
|
+
* Cloudflare's record ID, from `GetAtt`. This is the value you can use to
|
|
104
|
+
* locate the record in the Cloudflare dashboard.
|
|
105
|
+
*/
|
|
106
|
+
recordId;
|
|
107
|
+
/**
|
|
108
|
+
* The fully-qualified name actually written to Cloudflare (e.g. `app.example.com`).
|
|
109
|
+
*/
|
|
110
|
+
domainName;
|
|
111
|
+
/**
|
|
112
|
+
* The underlying custom resource.
|
|
113
|
+
*/
|
|
114
|
+
resource;
|
|
115
|
+
constructor(scope, id, props) {
|
|
116
|
+
super(scope, id);
|
|
117
|
+
validateRecordProps(props);
|
|
118
|
+
const provider = provider_1.CloudflareDnsProvider.getOrCreate(this);
|
|
119
|
+
provider.grantSecretRead(props.zone.apiToken);
|
|
120
|
+
const fqdn = resolveRecordName(props.recordName, props.zone.zoneName);
|
|
121
|
+
const ttl = resolveTtl(this, props);
|
|
122
|
+
const content = props.content === undefined
|
|
123
|
+
? undefined
|
|
124
|
+
: chunkTxt(props.type, props.content);
|
|
125
|
+
const record = {
|
|
126
|
+
name: fqdn,
|
|
127
|
+
type: props.type,
|
|
128
|
+
ttl: ttl.toSeconds(),
|
|
129
|
+
};
|
|
130
|
+
if (props.proxied) {
|
|
131
|
+
record.proxied = true;
|
|
132
|
+
}
|
|
133
|
+
if (content !== undefined) {
|
|
134
|
+
record.content = content;
|
|
135
|
+
}
|
|
136
|
+
if (props.data !== undefined) {
|
|
137
|
+
record.data = props.data;
|
|
138
|
+
}
|
|
139
|
+
if (props.priority !== undefined) {
|
|
140
|
+
record.priority = props.priority;
|
|
141
|
+
}
|
|
142
|
+
if (props.comment !== undefined) {
|
|
143
|
+
record.comment = props.comment;
|
|
144
|
+
}
|
|
145
|
+
if (props.tags !== undefined) {
|
|
146
|
+
record.tags = props.tags;
|
|
147
|
+
}
|
|
148
|
+
const removalPolicy = props.removalPolicy ?? aws_cdk_lib_1.RemovalPolicy.DESTROY;
|
|
149
|
+
this.resource = new cdk.CustomResource(this, 'Resource', {
|
|
150
|
+
serviceToken: provider.serviceToken,
|
|
151
|
+
resourceType: 'Custom::CloudflareDnsRecord',
|
|
152
|
+
removalPolicy,
|
|
153
|
+
properties: {
|
|
154
|
+
zoneId: props.zone.zoneId,
|
|
155
|
+
apiTokenSecretArn: props.zone.apiToken.secretArn,
|
|
156
|
+
adoptExisting: props.adoptExisting ?? false,
|
|
157
|
+
retainOnDelete: removalPolicy === aws_cdk_lib_1.RemovalPolicy.RETAIN,
|
|
158
|
+
record,
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
this.recordId = this.resource.getAttString('RecordId');
|
|
162
|
+
this.domainName = this.resource.getAttString('DomainName');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.CloudflareRecord = CloudflareRecord;
|
|
166
|
+
/**
|
|
167
|
+
* Validates the record props at synth time, throwing a helpful error rather than
|
|
168
|
+
* deferring the failure to deployment.
|
|
169
|
+
*/
|
|
170
|
+
function validateRecordProps(props) {
|
|
171
|
+
const hasContent = props.content !== undefined;
|
|
172
|
+
const hasData = props.data !== undefined;
|
|
173
|
+
if (hasContent === hasData) {
|
|
174
|
+
throw new Error(`CloudflareRecord must specify exactly one of "content" or "data"; got content=${props.content === undefined ? 'undefined' : JSON.stringify(props.content)}, data=${props.data === undefined ? 'undefined' : 'object'}`);
|
|
175
|
+
}
|
|
176
|
+
if (props.proxied && !PROXIED_TYPES.has(props.type)) {
|
|
177
|
+
throw new Error(`CloudflareRecord "proxied" is only valid for A, AAAA and CNAME records, got ${props.type}`);
|
|
178
|
+
}
|
|
179
|
+
if (props.priority !== undefined && !PRIORITY_TYPES.has(props.type)) {
|
|
180
|
+
throw new Error(`CloudflareRecord "priority" is only valid for MX, SRV and URI records, got ${props.type}`);
|
|
181
|
+
}
|
|
182
|
+
if (props.priority === undefined && PRIORITY_TYPES.has(props.type)) {
|
|
183
|
+
throw new Error(`CloudflareRecord "priority" is required for ${props.type} records`);
|
|
184
|
+
}
|
|
185
|
+
if (props.ttl !== undefined) {
|
|
186
|
+
const seconds = props.ttl.toSeconds();
|
|
187
|
+
const isAuto = seconds === CloudflareTtl.AUTO.toSeconds();
|
|
188
|
+
if (!isAuto && (seconds < MIN_TTL_SECONDS || seconds > MAX_TTL_SECONDS)) {
|
|
189
|
+
throw new Error(`CloudflareRecord ttl must be between ${MIN_TTL_SECONDS} and ${MAX_TTL_SECONDS} seconds, or CloudflareTtl.AUTO (1); got ${seconds}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (props.type === CloudflareRecordType.TXT && hasContent && props.content !== undefined && props.content.length === 0) {
|
|
193
|
+
throw new Error('CloudflareRecord TXT records require non-empty content');
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Resolves the effective TTL for the record. Cloudflare rejects any TTL other
|
|
198
|
+
* than `1` when `proxied` is true, so the TTL is silently forced to automatic
|
|
199
|
+
* and an informational annotation is emitted.
|
|
200
|
+
*/
|
|
201
|
+
function resolveTtl(scope, props) {
|
|
202
|
+
const ttl = props.ttl ?? aws_cdk_lib_1.Duration.minutes(5);
|
|
203
|
+
if (props.proxied && ttl.toSeconds() !== CloudflareTtl.AUTO.toSeconds()) {
|
|
204
|
+
aws_cdk_lib_1.Annotations.of(scope).addInfo(`Cloudflare requires an automatic TTL (1) for proxied records; forcing ttl to CloudflareTtl.AUTO for ${props.type} record`);
|
|
205
|
+
return CloudflareTtl.AUTO;
|
|
206
|
+
}
|
|
207
|
+
return ttl;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Resolves a relative record name against the zone name, matching the
|
|
211
|
+
* `aws-cdk-lib/aws-route53` ergonomics.
|
|
212
|
+
*
|
|
213
|
+
* - `undefined` or `'@'` resolves to the zone apex.
|
|
214
|
+
* - A name that already ends in the zone name is used verbatim.
|
|
215
|
+
* - Anything else is treated as relative and the zone name is appended.
|
|
216
|
+
*/
|
|
217
|
+
function resolveRecordName(recordName, zoneName) {
|
|
218
|
+
if (recordName === undefined || recordName === '@') {
|
|
219
|
+
return zoneName ?? '@';
|
|
220
|
+
}
|
|
221
|
+
if (zoneName !== undefined && (recordName === zoneName || recordName.endsWith(`.${zoneName}`))) {
|
|
222
|
+
return recordName;
|
|
223
|
+
}
|
|
224
|
+
if (zoneName !== undefined) {
|
|
225
|
+
return `${recordName}.${zoneName}`;
|
|
226
|
+
}
|
|
227
|
+
return recordName;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Chunks a TXT record value longer than 255 characters into a series of quoted
|
|
231
|
+
* segments, which is how multiple strings are encoded in a single TXT record.
|
|
232
|
+
*/
|
|
233
|
+
function chunkTxt(type, content) {
|
|
234
|
+
if (type !== CloudflareRecordType.TXT || content.length <= 255) {
|
|
235
|
+
return content;
|
|
236
|
+
}
|
|
237
|
+
const chunks = [];
|
|
238
|
+
for (let i = 0; i < content.length; i += 255) {
|
|
239
|
+
chunks.push(content.slice(i, i + 255));
|
|
240
|
+
}
|
|
241
|
+
return chunks.map((chunk) => `"${chunk}"`).join(' ');
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* An A record.
|
|
245
|
+
*/
|
|
246
|
+
class CloudflareARecord extends CloudflareRecord {
|
|
247
|
+
constructor(scope, id, props) {
|
|
248
|
+
super(scope, id, { ...props, type: CloudflareRecordType.A });
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
exports.CloudflareARecord = CloudflareARecord;
|
|
252
|
+
/**
|
|
253
|
+
* An AAAA record.
|
|
254
|
+
*/
|
|
255
|
+
class CloudflareAaaaRecord extends CloudflareRecord {
|
|
256
|
+
constructor(scope, id, props) {
|
|
257
|
+
super(scope, id, { ...props, type: CloudflareRecordType.AAAA });
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
exports.CloudflareAaaaRecord = CloudflareAaaaRecord;
|
|
261
|
+
/**
|
|
262
|
+
* A CNAME record.
|
|
263
|
+
*/
|
|
264
|
+
class CloudflareCnameRecord extends CloudflareRecord {
|
|
265
|
+
constructor(scope, id, props) {
|
|
266
|
+
super(scope, id, { ...props, type: CloudflareRecordType.CNAME });
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
exports.CloudflareCnameRecord = CloudflareCnameRecord;
|
|
270
|
+
/**
|
|
271
|
+
* A TXT record.
|
|
272
|
+
*/
|
|
273
|
+
class CloudflareTxtRecord extends CloudflareRecord {
|
|
274
|
+
constructor(scope, id, props) {
|
|
275
|
+
super(scope, id, { ...props, type: CloudflareRecordType.TXT });
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
exports.CloudflareTxtRecord = CloudflareTxtRecord;
|
|
279
|
+
/**
|
|
280
|
+
* An MX record.
|
|
281
|
+
*/
|
|
282
|
+
class CloudflareMxRecord extends CloudflareRecord {
|
|
283
|
+
constructor(scope, id, props) {
|
|
284
|
+
super(scope, id, { ...props, type: CloudflareRecordType.MX });
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
exports.CloudflareMxRecord = CloudflareMxRecord;
|
|
288
|
+
/**
|
|
289
|
+
* A CAA record.
|
|
290
|
+
*/
|
|
291
|
+
class CloudflareCaaRecord extends CloudflareRecord {
|
|
292
|
+
constructor(scope, id, props) {
|
|
293
|
+
super(scope, id, { ...props, type: CloudflareRecordType.CAA });
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
exports.CloudflareCaaRecord = CloudflareCaaRecord;
|
|
297
|
+
//# sourceMappingURL=record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqSA,8CAcC;AAnTD,iDAAmC;AACnC,6CAAmE;AACnE,2CAAuC;AAEvC,yCAAmD;AAEnD;;GAEG;AACH,IAAY,oBAqBX;AArBD,WAAY,oBAAoB;IAC9B,8BAA8B;IAC9B,+BAAO,CAAA;IACP,8BAA8B;IAC9B,qCAAa,CAAA;IACb,+BAA+B;IAC/B,uCAAe,CAAA;IACf,qBAAqB;IACrB,mCAAW,CAAA;IACX,+BAA+B;IAC/B,iCAAS,CAAA;IACT,4BAA4B;IAC5B,iCAAS,CAAA;IACT,gCAAgC;IAChC,mCAAW,CAAA;IACX,sDAAsD;IACtD,mCAAW,CAAA;IACX,wBAAwB;IACxB,mCAAW,CAAA;IACX,4CAA4C;IAC5C,mCAAW,CAAA;AACb,CAAC,EArBW,oBAAoB,oCAApB,oBAAoB,QAqB/B;AAED;;GAEG;AACH,MAAa,aAAa;IACxB;;OAEG;IACI,MAAM,CAAU,IAAI,GAAa,sBAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;;AAJ9D,sCAKC;AAED;;GAEG;AACH,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,oBAAoB,CAAC,CAAC,EAAE,oBAAoB,CAAC,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;AAE/G;;GAEG;AACH,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,oBAAoB,CAAC,EAAE,EAAE,oBAAoB,CAAC,GAAG,EAAE,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC;AAE9G;;GAEG;AACH,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B;;GAEG;A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AChF,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,oBAAoB,CAAC,KAAK,EAAE,CAAC,CAAC;IACnE,CAAC;CACF;AAJD,sDAIC;AAUD;;GAEG;AACH,MAAa,mBAAoB,SAAQ,gBAAgB;IACvD,YAAmB,KAAgB,EAAE,EAAU,EAAE,KAA+B;QAC9E,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,oBAAoB,CAAC,GAAG,EAAE,CAAC,CAAC;IACjE,CAAC;CACF;AAJD,kDAIC;AAYD;;GAEG;AACH,MAAa,kBAAmB,SAAQ,gBAAgB;IACtD,YAAmB,KAAgB,EAAE,EAAU,EAAE,KAA8B;QAC7E,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,oBAAoB,CAAC,EAAE,EAAE,CAAC,CAAC;IAChE,CAAC;CACF;AAJD,gDAIC;AAUD;;GAEG;AACH,MAAa,mBAAoB,SAAQ,gBAAgB;IACvD,YAAmB,KAAgB,EAAE,EAAU,EAAE,KAA+B;QAC9E,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,oBAAoB,CAAC,GAAG,EAAE,CAAC,CAAC;IACjE,CAAC;CACF;AAJD,kDAIC"}
|
package/lib/zone.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
|
+
/**
|
|
4
|
+
* A reference to a Cloudflare zone that already exists in the Cloudflare account.
|
|
5
|
+
*
|
|
6
|
+
* `CloudflareZone.fromZoneId()` is the only supported way to obtain one; this
|
|
7
|
+
* library deliberately does not create zones. Zones are assumed to be managed in
|
|
8
|
+
* the Cloudflare dashboard (or elsewhere) and referenced here by their Zone ID.
|
|
9
|
+
*/
|
|
10
|
+
export interface ICloudflareZone {
|
|
11
|
+
/**
|
|
12
|
+
* The Cloudflare Zone ID, e.g. `"abc123..."`. This may be a plain string or a
|
|
13
|
+
* CDK token (for example resolved from SSM at deploy time).
|
|
14
|
+
*/
|
|
15
|
+
readonly zoneId: string;
|
|
16
|
+
/**
|
|
17
|
+
* The apex domain, e.g. `"example.com"`. When set, `recordName` values that do
|
|
18
|
+
* not already end in the zone name are treated as relative and this suffix is
|
|
19
|
+
* appended, matching `aws-cdk-lib/aws-route53` ergonomics.
|
|
20
|
+
*
|
|
21
|
+
* @default - record names are used verbatim
|
|
22
|
+
*/
|
|
23
|
+
readonly zoneName?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The Secrets Manager secret holding the Cloudflare API token. The secret may
|
|
26
|
+
* contain the token as a raw string or as a JSON blob with an `apiToken` key.
|
|
27
|
+
* Only the secret ARN ever appears in the CloudFormation template.
|
|
28
|
+
*/
|
|
29
|
+
readonly apiToken: secretsmanager.ISecret;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Properties for referencing an existing Cloudflare zone.
|
|
33
|
+
*/
|
|
34
|
+
export interface CloudflareZoneAttributes {
|
|
35
|
+
/**
|
|
36
|
+
* The Cloudflare Zone ID, e.g. `"abc123..."`. This may be a plain string or a
|
|
37
|
+
* CDK token (for example resolved from SSM at deploy time).
|
|
38
|
+
*/
|
|
39
|
+
readonly zoneId: string;
|
|
40
|
+
/**
|
|
41
|
+
* The Secrets Manager secret holding the Cloudflare API token. The secret may
|
|
42
|
+
* contain the token as a raw string or as a JSON blob with an `apiToken` key.
|
|
43
|
+
* Only the secret ARN ever appears in the CloudFormation template.
|
|
44
|
+
*/
|
|
45
|
+
readonly apiToken: secretsmanager.ISecret;
|
|
46
|
+
/**
|
|
47
|
+
* The apex domain, e.g. `"example.com"`. Enables relative record names.
|
|
48
|
+
*
|
|
49
|
+
* @default - record names are used verbatim
|
|
50
|
+
*/
|
|
51
|
+
readonly zoneName?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A reference to an existing Cloudflare zone.
|
|
55
|
+
*
|
|
56
|
+
* Zones are not created by this library; they must already exist in the
|
|
57
|
+
* Cloudflare account. Use `CloudflareZone.fromZoneId()` to reference one.
|
|
58
|
+
*/
|
|
59
|
+
export declare class CloudflareZone extends Construct implements ICloudflareZone {
|
|
60
|
+
/**
|
|
61
|
+
* Reference an existing Cloudflare zone by its Zone ID.
|
|
62
|
+
*
|
|
63
|
+
* @param scope The scope in which to define this construct.
|
|
64
|
+
* @param id The scoped construct ID.
|
|
65
|
+
* @param attrs The zone attributes.
|
|
66
|
+
*/
|
|
67
|
+
static fromZoneId(scope: Construct, id: string, attrs: CloudflareZoneAttributes): ICloudflareZone;
|
|
68
|
+
readonly zoneId: string;
|
|
69
|
+
readonly zoneName?: string;
|
|
70
|
+
readonly apiToken: secretsmanager.ISecret;
|
|
71
|
+
private constructor();
|
|
72
|
+
}
|