CaCertificate class

Creates and manages an AWS IoT CA Certificate.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as tls from "@pulumi/tls";

const caPrivateKey = new tls.PrivateKey("ca", {algorithm: "RSA"});
const ca = new tls.SelfSignedCert("ca", {
    subject: [{
        commonName: "example.com",
        organization: "ACME Examples, Inc",
    }],
    privateKeyPem: caPrivateKey.privateKeyPem,
    validityPeriodHours: 12,
    allowedUses: [
        "key_encipherment",
        "digital_signature",
        "server_auth",
    ],
    isCaCertificate: true,
});
const verificationPrivateKey = new tls.PrivateKey("verification", {algorithm: "RSA"});
const example = aws.iot.getRegistrationCode({});
const verification = new tls.CertRequest("verification", {
    subject: [{
        commonName: example.then(example => example.registrationCode),
    }],
    privateKeyPem: verificationPrivateKey.privateKeyPem,
});
const verificationLocallySignedCert = new tls.LocallySignedCert("verification", {
    certRequestPem: verification.certRequestPem,
    caPrivateKeyPem: caPrivateKey.privateKeyPem,
    caCertPem: ca.certPem,
    validityPeriodHours: 12,
    allowedUses: [
        "key_encipherment",
        "digital_signature",
        "server_auth",
    ],
});
const exampleCaCertificate = new aws.iot.CaCertificate("example", {
    active: true,
    caCertificatePem: ca.certPem,
    verificationCertificatePem: verificationLocallySignedCert.certPem,
    allowAutoRegistration: true,
});
import pulumi
import pulumi_aws as aws
import pulumi_tls as tls

ca_private_key = tls.PrivateKey("ca", algorithm="RSA")
ca = tls.SelfSignedCert("ca",
    subject=[{
        "commonName": "example.com",
        "organization": "ACME Examples, Inc",
    }],
    private_key_pem=ca_private_key.private_key_pem,
    validity_period_hours=12,
    allowed_uses=[
        "key_encipherment",
        "digital_signature",
        "server_auth",
    ],
    is_ca_certificate=True)
verification_private_key = tls.PrivateKey("verification", algorithm="RSA")
example = aws.iot.get_registration_code()
verification = tls.CertRequest("verification",
    subject=[{
        "commonName": example.registration_code,
    }],
    private_key_pem=verification_private_key.private_key_pem)
verification_locally_signed_cert = tls.LocallySignedCert("verification",
    cert_request_pem=verification.cert_request_pem,
    ca_private_key_pem=ca_private_key.private_key_pem,
    ca_cert_pem=ca.cert_pem,
    validity_period_hours=12,
    allowed_uses=[
        "key_encipherment",
        "digital_signature",
        "server_auth",
    ])
example_ca_certificate = aws.iot.CaCertificate("example",
    active=True,
    ca_certificate_pem=ca.cert_pem,
    verification_certificate_pem=verification_locally_signed_cert.cert_pem,
    allow_auto_registration=True)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
using Tls = Pulumi.Tls;

return await Deployment.RunAsync(() =>
{
    var caPrivateKey = new Tls.PrivateKey("ca", new()
    {
        Algorithm = "RSA",
    });

    var ca = new Tls.SelfSignedCert("ca", new()
    {
        Subject = new[]
        {

            {
                { "commonName", "example.com" },
                { "organization", "ACME Examples, Inc" },
            },
        },
        PrivateKeyPem = caPrivateKey.PrivateKeyPem,
        ValidityPeriodHours = 12,
        AllowedUses = new[]
        {
            "key_encipherment",
            "digital_signature",
            "server_auth",
        },
        IsCaCertificate = true,
    });

    var verificationPrivateKey = new Tls.PrivateKey("verification", new()
    {
        Algorithm = "RSA",
    });

    var example = Aws.Iot.GetRegistrationCode.Invoke();

    var verification = new Tls.CertRequest("verification", new()
    {
        Subject = new[]
        {

            {
                { "commonName", example.Apply(getRegistrationCodeResult => getRegistrationCodeResult.RegistrationCode) },
            },
        },
        PrivateKeyPem = verificationPrivateKey.PrivateKeyPem,
    });

    var verificationLocallySignedCert = new Tls.LocallySignedCert("verification", new()
    {
        CertRequestPem = verification.CertRequestPem,
        CaPrivateKeyPem = caPrivateKey.PrivateKeyPem,
        CaCertPem = ca.CertPem,
        ValidityPeriodHours = 12,
        AllowedUses = new[]
        {
            "key_encipherment",
            "digital_signature",
            "server_auth",
        },
    });

    var exampleCaCertificate = new Aws.Iot.CaCertificate("example", new()
    {
        Active = true,
        CaCertificatePem = ca.CertPem,
        VerificationCertificatePem = verificationLocallySignedCert.CertPem,
        AllowAutoRegistration = true,
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iot"
	"github.com/pulumi/pulumi-tls/sdk/v5/go/tls"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		caPrivateKey, err := tls.NewPrivateKey(ctx, "ca", &tls.PrivateKeyArgs{
			Algorithm: pulumi.String("RSA"),
		})
		if err != nil {
			return err
		}
		ca, err := tls.NewSelfSignedCert(ctx, "ca", &tls.SelfSignedCertArgs{
			Subject: tls.SelfSignedCertSubjectArgs{
				map[string]string{
					"commonName":   "example.com",
					"organization": "ACME Examples, Inc",
				},
			},
			PrivateKeyPem:       caPrivateKey.PrivateKeyPem,
			ValidityPeriodHours: pulumi.Int(12),
			AllowedUses: pulumi.StringArray{
				pulumi.String("key_encipherment"),
				pulumi.String("digital_signature"),
				pulumi.String("server_auth"),
			},
			IsCaCertificate: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		verificationPrivateKey, err := tls.NewPrivateKey(ctx, "verification", &tls.PrivateKeyArgs{
			Algorithm: pulumi.String("RSA"),
		})
		if err != nil {
			return err
		}
		example, err := iot.GetRegistrationCode(ctx, &iot.GetRegistrationCodeArgs{}, nil)
		if err != nil {
			return err
		}
		verification, err := tls.NewCertRequest(ctx, "verification", &tls.CertRequestArgs{
			Subject: tls.CertRequestSubjectArgs{
				map[string]interface{}{
					"commonName": example.RegistrationCode,
				},
			},
			PrivateKeyPem: verificationPrivateKey.PrivateKeyPem,
		})
		if err != nil {
			return err
		}
		verificationLocallySignedCert, err := tls.NewLocallySignedCert(ctx, "verification", &tls.LocallySignedCertArgs{
			CertRequestPem:      verification.CertRequestPem,
			CaPrivateKeyPem:     caPrivateKey.PrivateKeyPem,
			CaCertPem:           ca.CertPem,
			ValidityPeriodHours: pulumi.Int(12),
			AllowedUses: pulumi.StringArray{
				pulumi.String("key_encipherment"),
				pulumi.String("digital_signature"),
				pulumi.String("server_auth"),
			},
		})
		if err != nil {
			return err
		}
		_, err = iot.NewCaCertificate(ctx, "example", &iot.CaCertificateArgs{
			Active:                     pulumi.Bool(true),
			CaCertificatePem:           ca.CertPem,
			VerificationCertificatePem: verificationLocallySignedCert.CertPem,
			AllowAutoRegistration:      pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
    tls = {
      source = "pulumi/tls"
    }
  }
}

data "aws_iot_getregistrationcode" "example" {
}

resource "tls_selfsignedcert" "ca" {
  subject = [{
    "commonName"   = "example.com"
    "organization" = "ACME Examples, Inc"
  }]
  private_key_pem       = tls_privatekey.ca.private_key_pem
  validity_period_hours = 12
  allowed_uses          = ["key_encipherment", "digital_signature", "server_auth"]
  is_ca_certificate     = true
}
resource "tls_privatekey" "ca" {
  algorithm = "RSA"
}
resource "tls_certrequest" "verification" {
  subject = [{
    "commonName" = data.aws_iot_getregistrationcode.example.registration_code
  }]
  private_key_pem = tls_privatekey.verification.private_key_pem
}
resource "tls_privatekey" "verification" {
  algorithm = "RSA"
}
resource "tls_locallysignedcert" "verification" {
  cert_request_pem      = tls_certrequest.verification.cert_request_pem
  ca_private_key_pem    = tls_privatekey.ca.private_key_pem
  ca_cert_pem           = tls_selfsignedcert.ca.cert_pem
  validity_period_hours = 12
  allowed_uses          = ["key_encipherment", "digital_signature", "server_auth"]
}
resource "aws_iot_cacertificate" "example" {
  active                       = true
  ca_certificate_pem           = tls_selfsignedcert.ca.cert_pem
  verification_certificate_pem = tls_locallysignedcert.verification.cert_pem
  allow_auto_registration      = true
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.tls.PrivateKey;
import com.pulumi.tls.PrivateKeyArgs;
import com.pulumi.tls.SelfSignedCert;
import com.pulumi.tls.SelfSignedCertArgs;
import com.pulumi.aws.iot.IotFunctions;
import com.pulumi.aws.iot.inputs.GetRegistrationCodeArgs;
import com.pulumi.tls.CertRequest;
import com.pulumi.tls.CertRequestArgs;
import com.pulumi.tls.LocallySignedCert;
import com.pulumi.tls.LocallySignedCertArgs;
import com.pulumi.aws.iot.CaCertificate;
import com.pulumi.aws.iot.CaCertificateArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var caPrivateKey = new PrivateKey("caPrivateKey", PrivateKeyArgs.builder()
            .algorithm("RSA")
            .build());

        var ca = new SelfSignedCert("ca", SelfSignedCertArgs.builder()
            .subject(com.pulumi.tls.inputs.SelfSignedCertSubjectArgs.builder()
                .commonName("example.com")
                .organization("ACME Examples, Inc")
                .build())
            .privateKeyPem(caPrivateKey.privateKeyPem())
            .validityPeriodHours(12)
            .allowedUses(
                "key_encipherment",
                "digital_signature",
                "server_auth")
            .isCaCertificate(true)
            .build());

        var verificationPrivateKey = new PrivateKey("verificationPrivateKey", PrivateKeyArgs.builder()
            .algorithm("RSA")
            .build());

        final var example = IotFunctions.getRegistrationCode(GetRegistrationCodeArgs.builder()
            .build());

        var verification = new CertRequest("verification", CertRequestArgs.builder()
            .subject(com.pulumi.tls.inputs.CertRequestSubjectArgs.builder()
                .commonName(example.registrationCode())
                .build())
            .privateKeyPem(verificationPrivateKey.privateKeyPem())
            .build());

        var verificationLocallySignedCert = new LocallySignedCert("verificationLocallySignedCert", LocallySignedCertArgs.builder()
            .certRequestPem(verification.certRequestPem())
            .caPrivateKeyPem(caPrivateKey.privateKeyPem())
            .caCertPem(ca.certPem())
            .validityPeriodHours(12)
            .allowedUses(
                "key_encipherment",
                "digital_signature",
                "server_auth")
            .build());

        var exampleCaCertificate = new CaCertificate("exampleCaCertificate", CaCertificateArgs.builder()
            .active(true)
            .caCertificatePem(ca.certPem())
            .verificationCertificatePem(verificationLocallySignedCert.certPem())
            .allowAutoRegistration(true)
            .build());

    }
}
resources:
  ca:
    type: tls:SelfSignedCert
    properties:
      subject:
        - commonName: example.com
          organization: ACME Examples, Inc
      privateKeyPem: ${caPrivateKey.privateKeyPem}
      validityPeriodHours: 12
      allowedUses:
        - key_encipherment
        - digital_signature
        - server_auth
      isCaCertificate: true
  caPrivateKey:
    type: tls:PrivateKey
    name: ca
    properties:
      algorithm: RSA
  verification:
    type: tls:CertRequest
    properties:
      subject:
        - commonName: ${example.registrationCode}
      privateKeyPem: ${verificationPrivateKey.privateKeyPem}
  verificationPrivateKey:
    type: tls:PrivateKey
    name: verification
    properties:
      algorithm: RSA
  verificationLocallySignedCert:
    type: tls:LocallySignedCert
    name: verification
    properties:
      certRequestPem: ${verification.certRequestPem}
      caPrivateKeyPem: ${caPrivateKey.privateKeyPem}
      caCertPem: ${ca.certPem}
      validityPeriodHours: 12
      allowedUses:
        - key_encipherment
        - digital_signature
        - server_auth
  exampleCaCertificate:
    type: aws:iot:CaCertificate
    name: example
    properties:
      active: true
      caCertificatePem: ${ca.certPem}
      verificationCertificatePem: ${verificationLocallySignedCert.certPem}
      allowAutoRegistration: true
variables:
  example:
    fn::invoke:
      function: aws:iot:getRegistrationCode
      arguments: {}

Constructors

CaCertificate(String name, {CaCertificateArgs? args, CustomResourceOptions? options})
Creates a new CaCertificate. name The Pulumi resource name. args Arguments used to configure this CaCertificate. The set of arguments for CaCertificate. options Resource options controlling this resource's behavior.
CaCertificate.reference(String urn)
Creates a typed reference to an existing CaCertificate resource.

Properties

active ↔ Output<bool>
Boolean flag to indicate if the certificate should be active for device authentication.
latefinal
allowAutoRegistration ↔ Output<bool>
Boolean flag to indicate if the certificate should be active for device regisration.
latefinal
arn ↔ Output<String>
The ARN of the created CA certificate.
latefinal
caCertificatePem ↔ Output<String>
PEM encoded CA certificate.
latefinal
certificateMode ↔ Output<String?>
The certificate mode in which the CA will be registered. Valid values: DEFAULT and SNI_ONLY. Default: DEFAULT.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
customerVersion ↔ Output<int>
The customer version of the CA certificate.
latefinal
generationId ↔ Output<String>
The generation ID of the CA certificate.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
registrationConfig ↔ Output<CaCertificateRegistrationConfig?>
Information about the registration configuration. See below.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tags ↔ Output<Map<String, String>?>
A map of tags to assign to the resource. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
latefinal
tagsAll ↔ Output<Map<String, String>>
A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited
validities ↔ Output<List<CaCertificateValidity>>
When the CA certificate is valid.
latefinal
verificationCertificatePem ↔ Output<String?>
PEM encoded verification certificate containing the common name of a registration code. Review CreateVerificationCSR. Required if certificateMode is DEFAULT.
latefinal

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {CaCertificateState? state, CustomResourceOptions? options}) → CaCertificate
Gets an existing CaCertificate resource's state with the given name and id.