UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 17.9 kB
"use strict";var __runInitializers=exports&&exports.__runInitializers||function(thisArg,initializers,value){for(var useValue=arguments.length>2,i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0},__esDecorate=exports&&exports.__esDecorate||function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(f!==void 0&&typeof f!="function")throw new TypeError("Function expected");return f}for(var kind=contextIn.kind,key=kind==="getter"?"get":kind==="setter"?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),_,done=!1,i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]=p==="access"?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])(kind==="accessor"?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if(kind==="accessor"){if(result===void 0)continue;if(result===null||typeof result!="object")throw new TypeError("Object expected");(_=accept(result.get))&&(descriptor.get=_),(_=accept(result.set))&&(descriptor.set=_),(_=accept(result.init))&&initializers.unshift(_)}else(_=accept(result))&&(kind==="field"?initializers.unshift(_):descriptor[key]=_)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0};Object.defineProperty(exports,"__esModule",{value:!0}),exports.PrivateHostedZone=exports.PublicHostedZone=exports.HostedZone=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var hosted_zone_grants_1=()=>{var tmp=require("./hosted-zone-grants");return hosted_zone_grants_1=()=>tmp,tmp},key_signing_key_1=()=>{var tmp=require("./key-signing-key");return key_signing_key_1=()=>tmp,tmp},record_set_1=()=>{var tmp=require("./record-set");return record_set_1=()=>tmp,tmp},route53_generated_1=()=>{var tmp=require("./route53.generated");return route53_generated_1=()=>tmp,tmp},util_1=()=>{var tmp=require("./util");return util_1=()=>tmp,tmp},iam=()=>{var tmp=require("../../aws-iam");return iam=()=>tmp,tmp},cxschema=()=>{var tmp=require("../../cloud-assembly-schema");return cxschema=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},errors_1=()=>{var tmp=require("../../core/lib/errors");return errors_1=()=>tmp,tmp},metadata_resource_1=()=>{var tmp=require("../../core/lib/metadata-resource");return metadata_resource_1=()=>tmp,tmp},prop_injectable_1=()=>{var tmp=require("../../core/lib/prop-injectable");return prop_injectable_1=()=>tmp,tmp};let HostedZone=(()=>{let _classDecorators=[prop_injectable_1().propertyInjectable],_classDescriptor,_classExtraInitializers=[],_classThis,_classSuper=core_1().Resource,_instanceExtraInitializers=[],_addVpc_decorators,_grantDelegation_decorators,_enableDnssec_decorators;var HostedZone2=class extends _classSuper{static{_classThis=this}static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;_addVpc_decorators=[(0,metadata_resource_1().MethodMetadata)()],_grantDelegation_decorators=[(0,metadata_resource_1().MethodMetadata)()],_enableDnssec_decorators=[(0,metadata_resource_1().MethodMetadata)()],__esDecorate(this,null,_addVpc_decorators,{kind:"method",name:"addVpc",static:!1,private:!1,access:{has:obj=>"addVpc"in obj,get:obj=>obj.addVpc},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,_grantDelegation_decorators,{kind:"method",name:"grantDelegation",static:!1,private:!1,access:{has:obj=>"grantDelegation"in obj,get:obj=>obj.grantDelegation},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,_enableDnssec_decorators,{kind:"method",name:"enableDnssec",static:!1,private:!1,access:{has:obj=>"enableDnssec"in obj,get:obj=>obj.enableDnssec},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(null,_classDescriptor={value:_classThis},_classDecorators,{kind:"class",name:_classThis.name,metadata:_metadata},null,_classExtraInitializers),HostedZone2=_classThis=_classDescriptor.value,_metadata&&Object.defineProperty(_classThis,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_route53.HostedZone",version:"2.233.0"};static PROPERTY_INJECTION_ID="aws-cdk-lib.aws-route53.HostedZone";get hostedZoneArn(){return(0,util_1().makeHostedZoneArn)(this,this.hostedZoneId)}get name(){return this.zoneName}static fromHostedZoneId(scope,id,hostedZoneId){class Import extends core_1().Resource{hostedZoneId=hostedZoneId;get name(){return this.zoneName}get zoneName(){throw new(errors_1()).ValidationError("Cannot reference `zoneName` when using `HostedZone.fromHostedZoneId()`. A construct consuming this hosted zone may be trying to reference its `zoneName`. If this is the case, use `fromHostedZoneAttributes()` or `fromLookup()` instead.",this)}get hostedZoneArn(){return(0,util_1().makeHostedZoneArn)(this,this.hostedZoneId)}grantDelegation(grantee,options){return hosted_zone_grants_1().HostedZoneGrants.fromHostedZone(this).delegation(grantee,options)}get hostedZoneRef(){return{hostedZoneId:this.hostedZoneId}}}return new Import(scope,id)}static fromHostedZoneAttributes(scope,id,attrs){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_route53_HostedZoneAttributes(attrs)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromHostedZoneAttributes),error}class Import extends core_1().Resource{hostedZoneId=attrs.hostedZoneId;zoneName=attrs.zoneName;name=attrs.zoneName;get hostedZoneArn(){return(0,util_1().makeHostedZoneArn)(this,this.hostedZoneId)}grantDelegation(grantee,options){return hosted_zone_grants_1().HostedZoneGrants.fromHostedZone(this).delegation(grantee,options)}get hostedZoneRef(){return{hostedZoneId:this.hostedZoneId}}}return new Import(scope,id)}static fromLookup(scope,id,query){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_route53_HostedZoneProviderProps(query)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromLookup),error}if(!query.domainName)throw new(errors_1()).ValidationError("Cannot use undefined value for attribute `domainName`",scope);const DEFAULT_HOSTED_ZONE={Id:"DUMMY",Name:query.domainName},response=core_1().ContextProvider.getValue(scope,{provider:cxschema().ContextProvider.HOSTED_ZONE_PROVIDER,dummyValue:DEFAULT_HOSTED_ZONE,props:query}).value;return response.Name.endsWith(".")&&(response.Name=response.Name.substring(0,response.Name.length-1)),response.Id=response.Id.replace("/hostedzone/",""),HostedZone2.fromHostedZoneAttributes(scope,id,{hostedZoneId:response.Id,zoneName:response.Name})}hostedZoneId=__runInitializers(this,_instanceExtraInitializers);zoneName;hostedZoneNameServers;vpcs=new Array;keySigningKey;grants=hosted_zone_grants_1().HostedZoneGrants.fromHostedZone(this);constructor(scope,id,props){super(scope,id);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_route53_HostedZoneProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,HostedZone2),error}(0,metadata_resource_1().addConstructMetadata)(this,props),(0,util_1().validateZoneName)(props.zoneName);const zoneName=props.addTrailingDot===!1||props.zoneName.endsWith(".")?props.zoneName:`${props.zoneName}.`,resource=new(route53_generated_1()).CfnHostedZone(this,"Resource",{name:zoneName,hostedZoneConfig:props.comment?{comment:props.comment}:void 0,queryLoggingConfig:props.queryLogsLogGroupArn?{cloudWatchLogsLogGroupArn:props.queryLogsLogGroupArn}:void 0,vpcs:core_1().Lazy.any({produce:()=>this.vpcs.length===0?void 0:this.vpcs})});this.hostedZoneId=resource.ref,this.hostedZoneNameServers=resource.attrNameServers,this.zoneName=props.zoneName;for(const vpc of props.vpcs||[])this.addVpc(vpc)}get hostedZoneRef(){return{hostedZoneId:this.hostedZoneId}}addVpc(vpc){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_IVpc(vpc)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addVpc),error}this.vpcs.push({vpcId:vpc.vpcId,vpcRegion:vpc.env.region??core_1().Stack.of(vpc).region})}grantDelegation(grantee,options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_iam_IGrantable(grantee),jsiiDeprecationWarnings().aws_cdk_lib_aws_route53_GrantDelegationOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.grantDelegation),error}return this.grants.delegation(grantee,options)}enableDnssec(options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_route53_ZoneSigningOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.enableDnssec),error}if(this.keySigningKey)throw new(errors_1()).ValidationError("DNSSEC is already enabled for this hosted zone",this);return this.keySigningKey=new(key_signing_key_1()).KeySigningKey(this,"KeySigningKey",{hostedZone:this,keySigningKeyName:options.keySigningKeyName,kmsKey:options.kmsKey}),new(route53_generated_1()).CfnDNSSEC(this,"DNSSEC",{hostedZoneId:this.hostedZoneId}).addDependency(this.keySigningKey.node.defaultChild),this.keySigningKey}static{__runInitializers(_classThis,_classExtraInitializers)}};return HostedZone2=_classThis})();exports.HostedZone=HostedZone;let PublicHostedZone=(()=>{let _classDecorators=[prop_injectable_1().propertyInjectable],_classDescriptor,_classExtraInitializers=[],_classThis,_classSuper=HostedZone,_instanceExtraInitializers=[],_addVpc_decorators,_addDelegation_decorators;var PublicHostedZone2=class extends _classSuper{static{_classThis=this}static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;_addVpc_decorators=[(0,metadata_resource_1().MethodMetadata)()],_addDelegation_decorators=[(0,metadata_resource_1().MethodMetadata)()],__esDecorate(this,null,_addVpc_decorators,{kind:"method",name:"addVpc",static:!1,private:!1,access:{has:obj=>"addVpc"in obj,get:obj=>obj.addVpc},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,_addDelegation_decorators,{kind:"method",name:"addDelegation",static:!1,private:!1,access:{has:obj=>"addDelegation"in obj,get:obj=>obj.addDelegation},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(null,_classDescriptor={value:_classThis},_classDecorators,{kind:"class",name:_classThis.name,metadata:_metadata},null,_classExtraInitializers),PublicHostedZone2=_classThis=_classDescriptor.value,_metadata&&Object.defineProperty(_classThis,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_route53.PublicHostedZone",version:"2.233.0"};static PROPERTY_INJECTION_ID="aws-cdk-lib.aws-route53.PublicHostedZone";static fromPublicHostedZoneId(scope,id,publicHostedZoneId){class Import extends core_1().Resource{hostedZoneId=publicHostedZoneId;get name(){return this.zoneName}get zoneName(){throw new(errors_1()).ValidationError("Cannot reference `zoneName` when using `PublicHostedZone.fromPublicHostedZoneId()`. A construct consuming this hosted zone may be trying to reference its `zoneName`. If this is the case, use `fromPublicHostedZoneAttributes()` instead",this)}get hostedZoneArn(){return(0,util_1().makeHostedZoneArn)(this,this.hostedZoneId)}grantDelegation(grantee,options){return hosted_zone_grants_1().HostedZoneGrants.fromHostedZone(this).delegation(grantee,options)}get hostedZoneRef(){return{hostedZoneId:this.hostedZoneId}}}return new Import(scope,id)}static fromPublicHostedZoneAttributes(scope,id,attrs){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_route53_PublicHostedZoneAttributes(attrs)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromPublicHostedZoneAttributes),error}class Import extends core_1().Resource{hostedZoneId=attrs.hostedZoneId;zoneName=attrs.zoneName;name=attrs.zoneName;get hostedZoneArn(){return(0,util_1().makeHostedZoneArn)(this,this.hostedZoneId)}grantDelegation(grantee,options){return hosted_zone_grants_1().HostedZoneGrants.fromHostedZone(this).delegation(grantee,options)}get hostedZoneRef(){return{hostedZoneId:this.zoneName}}}return new Import(scope,id)}crossAccountZoneDelegationRole=__runInitializers(this,_instanceExtraInitializers);constructor(scope,id,props){super(scope,id,props);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_route53_PublicHostedZoneProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,PublicHostedZone2),error}if((0,metadata_resource_1().addConstructMetadata)(this,props),props.caaAmazon&&new(record_set_1()).CaaAmazonRecord(this,"CaaAmazon",{zone:this}),!props.crossAccountZoneDelegationPrincipal&&props.crossAccountZoneDelegationRoleName)throw Error("crossAccountZoneDelegationRoleName property is not supported without crossAccountZoneDelegationPrincipal");props.crossAccountZoneDelegationPrincipal&&(this.crossAccountZoneDelegationRole=new(iam()).Role(this,"CrossAccountZoneDelegationRole",{roleName:props.crossAccountZoneDelegationRoleName,assumedBy:props.crossAccountZoneDelegationPrincipal,inlinePolicies:{delegation:new(iam()).PolicyDocument({statements:[new(iam()).PolicyStatement({actions:["route53:ChangeResourceRecordSets"],resources:[this.hostedZoneArn],conditions:{"ForAllValues:StringEquals":{"route53:ChangeResourceRecordSetsRecordTypes":["NS"],"route53:ChangeResourceRecordSetsActions":["UPSERT","DELETE"]}}}),new(iam()).PolicyStatement({actions:["route53:ListHostedZonesByName"],resources:["*"]})]})}}))}addVpc(_vpc){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ec2_IVpc(_vpc)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addVpc),error}throw new(errors_1()).ValidationError("Cannot associate public hosted zones with a VPC",this)}addDelegation(delegate,opts={}){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_route53_IPublicHostedZone(delegate),jsiiDeprecationWarnings().aws_cdk_lib_aws_route53_ZoneDelegationOptions(opts)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addDelegation),error}new(record_set_1()).ZoneDelegationRecord(this,`${this.zoneName} -> ${delegate.zoneName}`,{zone:this,recordName:delegate.zoneName,nameServers:delegate.hostedZoneNameServers,comment:opts.comment,ttl:opts.ttl})}static{__runInitializers(_classThis,_classExtraInitializers)}};return PublicHostedZone2=_classThis})();exports.PublicHostedZone=PublicHostedZone;let PrivateHostedZone=(()=>{let _classDecorators=[prop_injectable_1().propertyInjectable],_classDescriptor,_classExtraInitializers=[],_classThis,_classSuper=HostedZone;var PrivateHostedZone2=class extends _classSuper{static{_classThis=this}static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;__esDecorate(null,_classDescriptor={value:_classThis},_classDecorators,{kind:"class",name:_classThis.name,metadata:_metadata},null,_classExtraInitializers),PrivateHostedZone2=_classThis=_classDescriptor.value,_metadata&&Object.defineProperty(_classThis,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_route53.PrivateHostedZone",version:"2.233.0"};static PROPERTY_INJECTION_ID="aws-cdk-lib.aws-route53.PrivateHostedZone";static fromPrivateHostedZoneId(scope,id,privateHostedZoneId){class Import extends core_1().Resource{hostedZoneId=privateHostedZoneId;get name(){return this.zoneName}get zoneName(){throw new(errors_1()).ValidationError("Cannot reference `zoneName` when using `PrivateHostedZone.fromPrivateHostedZoneId()`. A construct consuming this hosted zone may be trying to reference its `zoneName`",this)}get hostedZoneArn(){return(0,util_1().makeHostedZoneArn)(this,this.hostedZoneId)}grantDelegation(grantee,options){return hosted_zone_grants_1().HostedZoneGrants.fromHostedZone(this).delegation(grantee,options)}get hostedZoneRef(){return{hostedZoneId:this.hostedZoneId}}}return new Import(scope,id)}static fromPrivateHostedZoneAttributes(scope,id,attrs){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_route53_PrivateHostedZoneAttributes(attrs)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromPrivateHostedZoneAttributes),error}class Import extends core_1().Resource{hostedZoneId=attrs.hostedZoneId;zoneName=attrs.zoneName;get name(){return this.zoneName}get hostedZoneArn(){return(0,util_1().makeHostedZoneArn)(this,this.hostedZoneId)}grantDelegation(grantee,options){return hosted_zone_grants_1().HostedZoneGrants.fromHostedZone(this).delegation(grantee,options)}get hostedZoneRef(){return{hostedZoneId:this.hostedZoneId}}}return new Import(scope,id)}constructor(scope,id,props){super(scope,id,props);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_route53_PrivateHostedZoneProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,PrivateHostedZone2),error}(0,metadata_resource_1().addConstructMetadata)(this,props),this.addVpc(props.vpc)}static{__runInitializers(_classThis,_classExtraInitializers)}};return PrivateHostedZone2=_classThis})();exports.PrivateHostedZone=PrivateHostedZone;