constructor()

in cdk/src/lib/certificate-stack.ts [26:57]


  constructor(scope: Construct, id: string, props?: CertificateStackProps) {
    super(scope, id, props);

    let certificate = null;

    // Provision a public certificate
    if (!props?.isPrivate) {
      // If route53 is the DNS provider, validation is done automatically
      if (props?.hostedZoneId) {
        const hostedZone = route53.HostedZone.fromHostedZoneId(this, 'HostedZone', props?.hostedZoneId!);
        certificate = new acm.Certificate(this, props?.certificateName!, {
          domainName: props?.domainName!,
          validation: acm.CertificateValidation.fromDns(hostedZone),
        });
      } else {
        certificate = new acm.Certificate(this, props?.certificateName!, {
          domainName: props?.domainName!,
          validation: props?.validationType === 'DNS' ? acm.CertificateValidation.fromDns() : acm.CertificateValidation.fromEmail(),
        });
      }
    } else {
      certificate = new acm.PrivateCertificate(this, props?.certificateName!, {
        domainName: props?.domainName!,
        certificateAuthority: acmpca.CertificateAuthority.fromCertificateAuthorityArn(this, 'CertificateAuthority', props?.pcaArn!),
      });
    }

    this.certificateArn = certificate.certificateArn;

    new cdk.CfnOutput(this, 'CertificateArn', { value: this.certificateArn });
    new cdk.CfnOutput(this, 'DomainName', { value: props!.domainName });
  }