UNPKG

@studion/infra-code-blocks

Version:
46 lines (45 loc) 2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AcmCertificate = void 0; const pulumi = require("@pulumi/pulumi"); const aws = require("@pulumi/aws"); const common_tags_1 = require("../../shared/common-tags"); class AcmCertificate extends pulumi.ComponentResource { certificate; certificateValidation; constructor(name, args, opts = {}) { super('studion:acm-certificate:AcmCertificate', name, {}, { ...opts, aliases: [...(opts.aliases || []), { type: 'studion:acm:Certificate' }], }); this.certificate = new aws.acm.Certificate(`${args.domain}-certificate`, { domainName: args.domain, subjectAlternativeNames: args.subjectAlternativeNames, validationMethod: 'DNS', region: args.region, tags: common_tags_1.commonTags, }, { parent: this }); this.certificateValidation = this.createCertValidationRecords(args.domain, args.hostedZoneId, args.region); this.registerOutputs(); } createCertValidationRecords(domainName, hostedZoneId, region) { return this.certificate.domainValidationOptions.apply(domains => { const validationRecords = domains.map(domain => new aws.route53.Record(`${domain.domainName}-cert-validation-domain`, { name: domain.resourceRecordName, type: domain.resourceRecordType, zoneId: hostedZoneId, records: [domain.resourceRecordValue], ttl: 600, }, { parent: this, deleteBeforeReplace: true, })); return new aws.acm.CertificateValidation(`${domainName}-cert-validation`, { certificateArn: this.certificate.arn, validationRecordFqdns: validationRecords.map(record => record.fqdn), region, }, { parent: this }); }); } } exports.AcmCertificate = AcmCertificate;