UNPKG

38.1 kBJavaScriptView Raw
1"use strict";
2var _a, _b, _c;
3Object.defineProperty(exports, "__esModule", { value: true });
4exports.PrivateHostedZone = exports.PublicHostedZone = exports.HostedZone = void 0;
5const jsiiDeprecationWarnings = require("../.warnings.jsii.js");
6const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
7const iam = require("@aws-cdk/aws-iam");
8const cxschema = require("@aws-cdk/cloud-assembly-schema");
9const core_1 = require("@aws-cdk/core");
10const record_set_1 = require("./record-set");
11const route53_generated_1 = require("./route53.generated");
12const util_1 = require("./util");
13/**
14 * Container for records, and records contain information about how to route traffic for a
15 * specific domain, such as example.com and its subdomains (acme.example.com, zenith.example.com)
16 */
17class HostedZone extends core_1.Resource {
18 constructor(scope, id, props) {
19 super(scope, id);
20 /**
21 * VPCs to which this hosted zone will be added
22 */
23 this.vpcs = new Array();
24 try {
25 jsiiDeprecationWarnings._aws_cdk_aws_route53_HostedZoneProps(props);
26 }
27 catch (error) {
28 if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
29 Error.captureStackTrace(error, HostedZone);
30 }
31 throw error;
32 }
33 util_1.validateZoneName(props.zoneName);
34 const resource = new route53_generated_1.CfnHostedZone(this, 'Resource', {
35 name: props.zoneName + '.',
36 hostedZoneConfig: props.comment ? { comment: props.comment } : undefined,
37 queryLoggingConfig: props.queryLogsLogGroupArn ? { cloudWatchLogsLogGroupArn: props.queryLogsLogGroupArn } : undefined,
38 vpcs: core_1.Lazy.any({ produce: () => this.vpcs.length === 0 ? undefined : this.vpcs }),
39 });
40 this.hostedZoneId = resource.ref;
41 this.hostedZoneNameServers = resource.attrNameServers;
42 this.zoneName = props.zoneName;
43 for (const vpc of props.vpcs || []) {
44 this.addVpc(vpc);
45 }
46 }
47 get hostedZoneArn() {
48 return util_1.makeHostedZoneArn(this, this.hostedZoneId);
49 }
50 /**
51 * Import a Route 53 hosted zone defined either outside the CDK, or in a different CDK stack
52 *
53 * Use when hosted zone ID is known. Hosted zone name becomes unavailable through this query.
54 *
55 * @param scope the parent Construct for this Construct
56 * @param id the logical name of this Construct
57 * @param hostedZoneId the ID of the hosted zone to import
58 */
59 static fromHostedZoneId(scope, id, hostedZoneId) {
60 class Import extends core_1.Resource {
61 constructor() {
62 super(...arguments);
63 this.hostedZoneId = hostedZoneId;
64 }
65 get zoneName() {
66 throw new Error('HostedZone.fromHostedZoneId doesn\'t support "zoneName"');
67 }
68 get hostedZoneArn() {
69 return util_1.makeHostedZoneArn(this, this.hostedZoneId);
70 }
71 }
72 return new Import(scope, id);
73 }
74 /**
75 * Imports a hosted zone from another stack.
76 *
77 * Use when both hosted zone ID and hosted zone name are known.
78 *
79 * @param scope the parent Construct for this Construct
80 * @param id the logical name of this Construct
81 * @param attrs the HostedZoneAttributes (hosted zone ID and hosted zone name)
82 */
83 static fromHostedZoneAttributes(scope, id, attrs) {
84 try {
85 jsiiDeprecationWarnings._aws_cdk_aws_route53_HostedZoneAttributes(attrs);
86 }
87 catch (error) {
88 if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
89 Error.captureStackTrace(error, this.fromHostedZoneAttributes);
90 }
91 throw error;
92 }
93 class Import extends core_1.Resource {
94 constructor() {
95 super(...arguments);
96 this.hostedZoneId = attrs.hostedZoneId;
97 this.zoneName = attrs.zoneName;
98 }
99 get hostedZoneArn() {
100 return util_1.makeHostedZoneArn(this, this.hostedZoneId);
101 }
102 }
103 return new Import(scope, id);
104 }
105 /**
106 * Lookup a hosted zone in the current account/region based on query parameters.
107 * Requires environment, you must specify env for the stack.
108 *
109 * Use to easily query hosted zones.
110 *
111 * @see https://docs.aws.amazon.com/cdk/latest/guide/environments.html
112 */
113 static fromLookup(scope, id, query) {
114 try {
115 jsiiDeprecationWarnings._aws_cdk_aws_route53_HostedZoneProviderProps(query);
116 }
117 catch (error) {
118 if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
119 Error.captureStackTrace(error, this.fromLookup);
120 }
121 throw error;
122 }
123 const DEFAULT_HOSTED_ZONE = {
124 Id: 'DUMMY',
125 Name: query.domainName,
126 };
127 const response = core_1.ContextProvider.getValue(scope, {
128 provider: cxschema.ContextProvider.HOSTED_ZONE_PROVIDER,
129 dummyValue: DEFAULT_HOSTED_ZONE,
130 props: query,
131 }).value;
132 // CDK handles the '.' at the end, so remove it here
133 if (response.Name.endsWith('.')) {
134 response.Name = response.Name.substring(0, response.Name.length - 1);
135 }
136 response.Id = response.Id.replace('/hostedzone/', '');
137 return HostedZone.fromHostedZoneAttributes(scope, id, {
138 hostedZoneId: response.Id,
139 zoneName: response.Name,
140 });
141 }
142 /**
143 * Add another VPC to this private hosted zone.
144 *
145 * @param vpc the other VPC to add.
146 */
147 addVpc(vpc) {
148 this.vpcs.push({ vpcId: vpc.vpcId, vpcRegion: core_1.Stack.of(vpc).region });
149 }
150}
151exports.HostedZone = HostedZone;
152_a = JSII_RTTI_SYMBOL_1;
153HostedZone[_a] = { fqn: "@aws-cdk/aws-route53.HostedZone", version: "1.204.0" };
154/**
155 * Create a Route53 public hosted zone.
156 *
157 * @resource AWS::Route53::HostedZone
158 */
159class PublicHostedZone extends HostedZone {
160 constructor(scope, id, props) {
161 super(scope, id, props);
162 try {
163 jsiiDeprecationWarnings._aws_cdk_aws_route53_PublicHostedZoneProps(props);
164 }
165 catch (error) {
166 if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
167 Error.captureStackTrace(error, PublicHostedZone);
168 }
169 throw error;
170 }
171 if (props.caaAmazon) {
172 new record_set_1.CaaAmazonRecord(this, 'CaaAmazon', {
173 zone: this,
174 });
175 }
176 if (!props.crossAccountZoneDelegationPrincipal && props.crossAccountZoneDelegationRoleName) {
177 throw Error('crossAccountZoneDelegationRoleName property is not supported without crossAccountZoneDelegationPrincipal');
178 }
179 if (props.crossAccountZoneDelegationPrincipal) {
180 this.crossAccountZoneDelegationRole = new iam.Role(this, 'CrossAccountZoneDelegationRole', {
181 roleName: props.crossAccountZoneDelegationRoleName,
182 assumedBy: props.crossAccountZoneDelegationPrincipal,
183 inlinePolicies: {
184 delegation: new iam.PolicyDocument({
185 statements: [
186 new iam.PolicyStatement({
187 actions: ['route53:ChangeResourceRecordSets'],
188 resources: [this.hostedZoneArn],
189 }),
190 new iam.PolicyStatement({
191 actions: ['route53:ListHostedZonesByName'],
192 resources: ['*'],
193 }),
194 ],
195 }),
196 },
197 });
198 }
199 }
200 /**
201 * Import a Route 53 public hosted zone defined either outside the CDK, or in a different CDK stack
202 *
203 * @param scope the parent Construct for this Construct
204 * @param id the logical name of this Construct
205 * @param publicHostedZoneId the ID of the public hosted zone to import
206 */
207 static fromPublicHostedZoneId(scope, id, publicHostedZoneId) {
208 class Import extends core_1.Resource {
209 constructor() {
210 super(...arguments);
211 this.hostedZoneId = publicHostedZoneId;
212 }
213 get zoneName() { throw new Error('cannot retrieve "zoneName" from an an imported hosted zone'); }
214 get hostedZoneArn() {
215 return util_1.makeHostedZoneArn(this, this.hostedZoneId);
216 }
217 }
218 return new Import(scope, id);
219 }
220 /**
221 * Imports a public hosted zone from another stack.
222 *
223 * Use when both hosted zone ID and hosted zone name are known.
224 *
225 * @param scope the parent Construct for this Construct
226 * @param id the logical name of this Construct
227 * @param attrs the PublicHostedZoneAttributes (hosted zone ID and hosted zone name)
228 */
229 static fromPublicHostedZoneAttributes(scope, id, attrs) {
230 try {
231 jsiiDeprecationWarnings._aws_cdk_aws_route53_PublicHostedZoneAttributes(attrs);
232 }
233 catch (error) {
234 if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
235 Error.captureStackTrace(error, this.fromPublicHostedZoneAttributes);
236 }
237 throw error;
238 }
239 class Import extends core_1.Resource {
240 constructor() {
241 super(...arguments);
242 this.hostedZoneId = attrs.hostedZoneId;
243 this.zoneName = attrs.zoneName;
244 }
245 get hostedZoneArn() {
246 return util_1.makeHostedZoneArn(this, this.hostedZoneId);
247 }
248 }
249 return new Import(scope, id);
250 }
251 addVpc(_vpc) {
252 throw new Error('Cannot associate public hosted zones with a VPC');
253 }
254 /**
255 * Adds a delegation from this zone to a designated zone.
256 *
257 * @param delegate the zone being delegated to.
258 * @param opts options for creating the DNS record, if any.
259 */
260 addDelegation(delegate, opts = {}) {
261 try {
262 jsiiDeprecationWarnings._aws_cdk_aws_route53_IPublicHostedZone(delegate);
263 jsiiDeprecationWarnings._aws_cdk_aws_route53_ZoneDelegationOptions(opts);
264 }
265 catch (error) {
266 if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
267 Error.captureStackTrace(error, this.addDelegation);
268 }
269 throw error;
270 }
271 new record_set_1.ZoneDelegationRecord(this, `${this.zoneName} -> ${delegate.zoneName}`, {
272 zone: this,
273 recordName: delegate.zoneName,
274 nameServers: delegate.hostedZoneNameServers,
275 comment: opts.comment,
276 ttl: opts.ttl,
277 });
278 }
279}
280exports.PublicHostedZone = PublicHostedZone;
281_b = JSII_RTTI_SYMBOL_1;
282PublicHostedZone[_b] = { fqn: "@aws-cdk/aws-route53.PublicHostedZone", version: "1.204.0" };
283/**
284 * Create a Route53 private hosted zone for use in one or more VPCs.
285 *
286 * Note that `enableDnsHostnames` and `enableDnsSupport` must have been enabled
287 * for the VPC you're configuring for private hosted zones.
288 *
289 * @resource AWS::Route53::HostedZone
290 */
291class PrivateHostedZone extends HostedZone {
292 constructor(scope, id, props) {
293 super(scope, id, props);
294 try {
295 jsiiDeprecationWarnings._aws_cdk_aws_route53_PrivateHostedZoneProps(props);
296 }
297 catch (error) {
298 if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
299 Error.captureStackTrace(error, PrivateHostedZone);
300 }
301 throw error;
302 }
303 this.addVpc(props.vpc);
304 }
305 /**
306 * Import a Route 53 private hosted zone defined either outside the CDK, or in a different CDK stack
307 *
308 * @param scope the parent Construct for this Construct
309 * @param id the logical name of this Construct
310 * @param privateHostedZoneId the ID of the private hosted zone to import
311 */
312 static fromPrivateHostedZoneId(scope, id, privateHostedZoneId) {
313 class Import extends core_1.Resource {
314 constructor() {
315 super(...arguments);
316 this.hostedZoneId = privateHostedZoneId;
317 }
318 get zoneName() { throw new Error('cannot retrieve "zoneName" from an an imported hosted zone'); }
319 get hostedZoneArn() {
320 return util_1.makeHostedZoneArn(this, this.hostedZoneId);
321 }
322 }
323 return new Import(scope, id);
324 }
325}
326exports.PrivateHostedZone = PrivateHostedZone;
327_c = JSII_RTTI_SYMBOL_1;
328PrivateHostedZone[_c] = { fqn: "@aws-cdk/aws-route53.PrivateHostedZone", version: "1.204.0" };
329//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaG9zdGVkLXpvbmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJob3N0ZWQtem9uZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFDQSx3Q0FBd0M7QUFDeEMsMkRBQTJEO0FBQzNELHdDQUFpRjtBQUlqRiw2Q0FBcUU7QUFDckUsMkRBQW9EO0FBQ3BELGlDQUE2RDtBQTBDN0Q7OztHQUdHO0FBQ0gsTUFBYSxVQUFXLFNBQVEsZUFBUTtJQWdHdEMsWUFBWSxLQUFnQixFQUFFLEVBQVUsRUFBRSxLQUFzQjtRQUM5RCxLQUFLLENBQUMsS0FBSyxFQUFFLEVBQUUsQ0FBQyxDQUFDO1FBTm5COztXQUVHO1FBQ2dCLFNBQUksR0FBRyxJQUFJLEtBQUssRUFBNkIsQ0FBQzs7Ozs7OytDQTlGdEQsVUFBVTs7OztRQW1HbkIsdUJBQWdCLENBQUMsS0FBSyxDQUFDLFFBQVEsQ0FBQyxDQUFDO1FBRWpDLE1BQU0sUUFBUSxHQUFHLElBQUksaUNBQWEsQ0FBQyxJQUFJLEVBQUUsVUFBVSxFQUFFO1lBQ25ELElBQUksRUFBRSxLQUFLLENBQUMsUUFBUSxHQUFHLEdBQUc7WUFDMUIsZ0JBQWdCLEVBQUUsS0FBSyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUMsRUF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