Pulumi TLS

5.3.1 · active · verified Fri Apr 10

Pulumi TLS is a Python package that provides an interface to create and manage TLS (Transport Layer Security) resources within Pulumi programs. It allows for the programmatic generation of private keys, certificate signing requests, and self-signed certificates, which can then be used with other cloud providers. The library is currently at version 5.3.1 and typically sees frequent updates to align with its upstream Terraform provider and Pulumi's core bridge updates.

Warnings

Install

Imports

Quickstart

This example demonstrates how to create an RSA private key and then use it to generate a self-signed TLS certificate with specified validity and allowed uses.

import pulumi
import pulumi_tls as tls

# Create a new private key
private_key = tls.PrivateKey("example-private-key",
    algorithm="RSA",
    rsa_bits=2048)

# Create a self-signed certificate using the private key
self_signed_cert = tls.SelfSignedCert("example-self-signed-cert",
    private_key_pem=private_key.private_key_pem,
    validity_period_hours=8760, # 1 year
    early_renewal_hours=240,    # 10 days
    allowed_uses=[
        "key_encipherment",
        "digital_signature",
        "server_auth"
    ],
    dns_names=[
        "example.com",
        "www.example.com"
    ],
    subject={
        "common_name": "example.com",
        "organization": "Acme, Inc."
    })

pulumi.export("private_key_pem", private_key.private_key_pem)
pulumi.export("self_signed_certificate_pem", self_signed_cert.cert_pem)

view raw JSON →