constructor()

in packages/aws-rfdk/lib/core/lib/x509-certificate.ts [429:469]


  constructor(scope: Construct, id: string, props: X509CertificatePkcs12Props) {
    super(scope, id, {
      lambdaCode: Code.fromAsset(join(__dirname, '..', '..', 'lambdas', 'nodejs')),
      lambdaHandler: 'x509-certificate.convert',
      encryptionKey: props.encryptionKey,
    });

    props.sourceCertificate.grantFullRead(this.lambdaFunc);

    const properties: IX509CertificateEncodePkcs12 = {
      Passphrase: this.passphrase.secretArn,
      Secret: {
        NamePrefix: this.node.path,
        Description: this.node.path,
        EncryptionKey: props.encryptionKey?.keyArn,
        Tags: [
          {
            Key: this.uniqueTag.key,
            Value: this.uniqueTag.value,
          },
        ],
      },
      Certificate: {
        Cert: props.sourceCertificate.cert.secretArn,
        CertChain: props.sourceCertificate.certChain ? props.sourceCertificate.certChain.secretArn : '',
        Key: props.sourceCertificate.key.secretArn,
        Passphrase: props.sourceCertificate.passphrase.secretArn,
      },
    };

    const resource = new CustomResource(this, 'Default', {
      serviceToken: this.lambdaFunc.functionArn,
      properties,
      resourceType: 'Custom::RFDK_X509_PKCS12',
    });

    this.cert = Secret.fromSecretAttributes(this, 'Cert', {
      secretCompleteArn: Token.asString(resource.getAtt('Cert')),
      encryptionKey: props.encryptionKey,
    });
  }