aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 6.28 kB
JavaScript
var __decorate=exports&&exports.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r},_a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.DnsValidatedCertificate=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var certificate_base_1=()=>{var tmp=require("./certificate-base");return certificate_base_1=()=>tmp,tmp},iam=()=>{var tmp=require("../../aws-iam");return iam=()=>tmp,tmp},cdk=()=>{var tmp=require("../../core");return cdk=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_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},certificate_request_provider_generated_1=()=>{var tmp=require("../../custom-resource-handlers/dist/aws-certificatemanager/certificate-request-provider.generated");return certificate_request_provider_generated_1=()=>tmp,tmp};let DnsValidatedCertificate=class DnsValidatedCertificate2 extends certificate_base_1().CertificateBase{constructor(scope,id,props){super(scope,id);try{jsiiDeprecationWarnings().print("aws-cdk-lib.aws_certificatemanager.DnsValidatedCertificate","use {@link Certificate } instead"),jsiiDeprecationWarnings().aws_cdk_lib_aws_certificatemanager_DnsValidatedCertificateProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,DnsValidatedCertificate2),error}if((0,metadata_resource_1().addConstructMetadata)(this,props),props.keyAlgorithm&&cdk().Annotations.of(this).addWarningV2("@aws-cdk/aws-certificatemanager:keyAlgorithmIgnored","keyAlgorithm is ignored for DnsValidatedCertificate construct."),this.region=props.region,this.domainName=props.domainName,!core_1().Token.isUnresolved(props.domainName)&&props.domainName.length>64)throw new(cdk()).ValidationError("Domain name must be 64 characters or less",this);this.normalizedZoneName=props.hostedZone.zoneName,this.normalizedZoneName.endsWith(".")&&(this.normalizedZoneName=this.normalizedZoneName.substring(0,this.normalizedZoneName.length-1)),this.hostedZoneId=props.hostedZone.hostedZoneId.replace(/^\/hostedzone\//,""),this.tags=new(cdk()).TagManager(cdk().TagType.MAP,"AWS::CertificateManager::Certificate");let certificateTransparencyLoggingPreference;props.transparencyLoggingEnabled!==void 0&&(certificateTransparencyLoggingPreference=props.transparencyLoggingEnabled?"ENABLED":"DISABLED");const requestorFunction=new(certificate_request_provider_generated_1()).CertificateRequestCertificateRequestFunction(this,"CertificateRequestorFunction",{timeout:cdk().Duration.minutes(15),role:props.customResourceRole});requestorFunction.addToRolePolicy(new(iam()).PolicyStatement({actions:["acm:RequestCertificate","acm:DescribeCertificate","acm:DeleteCertificate","acm:AddTagsToCertificate"],resources:["*"]})),requestorFunction.addToRolePolicy(new(iam()).PolicyStatement({actions:["route53:GetChange"],resources:["*"]})),requestorFunction.addToRolePolicy(new(iam()).PolicyStatement({actions:["route53:changeResourceRecordSets"],resources:[`arn:${cdk().Stack.of(requestorFunction).partition}:route53:::hostedzone/${this.hostedZoneId}`],conditions:{"ForAllValues:StringEquals":{"route53:ChangeResourceRecordSetsRecordTypes":["CNAME"],"route53:ChangeResourceRecordSetsActions":props.cleanupRoute53Records?["UPSERT","DELETE"]:["UPSERT"]},"ForAllValues:StringLike":{"route53:ChangeResourceRecordSetsNormalizedRecordNames":[addWildcard(props.domainName),...(props.subjectAlternativeNames??[]).map(d=>addWildcard(d))]}}}));const certificate=new(cdk()).CustomResource(this,"CertificateRequestorResource",{serviceToken:requestorFunction.functionArn,properties:{DomainName:props.domainName,SubjectAlternativeNames:cdk().Lazy.list({produce:()=>props.subjectAlternativeNames},{omitEmpty:!0}),CertificateTransparencyLoggingPreference:certificateTransparencyLoggingPreference,HostedZoneId:this.hostedZoneId,Region:props.region,Route53Endpoint:props.route53Endpoint,RemovalPolicy:cdk().Lazy.any({produce:()=>this._removalPolicy}),CleanupRecords:props.cleanupRoute53Records?"true":void 0,Tags:cdk().Lazy.list({produce:()=>this.tags.renderTags()})}});this.certificateArn=certificate.getAtt("Arn").toString(),this.node.addValidation({validate:()=>this.validateDnsValidatedCertificate()})}applyRemovalPolicy(policy){try{jsiiDeprecationWarnings().print("aws-cdk-lib.aws_certificatemanager.DnsValidatedCertificate#applyRemovalPolicy","use {@link Certificate } instead"),jsiiDeprecationWarnings().aws_cdk_lib_RemovalPolicy(policy)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.applyRemovalPolicy),error}this._removalPolicy=policy}validateDnsValidatedCertificate(){const errors=[];return!cdk().Token.isUnresolved(this.normalizedZoneName)&&this.domainName!==this.normalizedZoneName&&!this.domainName.endsWith("."+this.normalizedZoneName)&&errors.push(`DNS zone ${this.normalizedZoneName} is not authoritative for certificate domain name ${this.domainName}`),errors}};exports.DnsValidatedCertificate=DnsValidatedCertificate,_a=JSII_RTTI_SYMBOL_1,DnsValidatedCertificate[_a]={fqn:"aws-cdk-lib.aws_certificatemanager.DnsValidatedCertificate",version:"2.202.0"},DnsValidatedCertificate.PROPERTY_INJECTION_ID="aws-cdk-lib.aws-certificatemanager.DnsValidatedCertificate",__decorate([(0,metadata_resource_1().MethodMetadata)()],DnsValidatedCertificate.prototype,"applyRemovalPolicy",null),exports.DnsValidatedCertificate=DnsValidatedCertificate=__decorate([prop_injectable_1().propertyInjectable],DnsValidatedCertificate);function addWildcard(domainName){return domainName.startsWith("*.")?domainName:`*.${domainName}`}
;