CDK Certbot DNS Route53

2.5.18 · active · verified Thu Apr 16

This Python AWS CDK construct automates the process of obtaining and renewing Let's Encrypt SSL/TLS certificates using Certbot. It leverages AWS Lambda to run Certbot, Route53 for DNS-01 challenges, and stores the certificates in an S3 bucket. The current version is 2.5.18, with releases occurring periodically to support new CDK features and bug fixes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to integrate the `CdkCertbotDnsRoute53` construct into an AWS CDK application. Replace the placeholder values for `domain_name`, `hosted_zone_id`, and `certbot_email` with your actual domain information. The example assumes `CDK_DEFAULT_ACCOUNT` and `CDK_DEFAULT_REGION` are set in your environment, but provides fallback placeholders. After synthesizing, deploy the stack using `cdk deploy CertbotStack`.

import os
from aws_cdk import App, Stack, Environment
from cdk_certbot_dns_route53.constructs import CdkCertbotDnsRoute53

# AWS environment details. For production, ensure these are correctly configured.
# The AWS account and region for deployment. Using default placeholders for demonstration.
account = os.environ.get("CDK_DEFAULT_ACCOUNT", "123456789012") # Replace with your AWS Account ID
region = os.environ.get("CDK_DEFAULT_REGION", "us-east-1") # Replace with your AWS Region

app = App()

env_config = Environment(account=account, region=region)

stack = Stack(
    app,
    "CertbotStack",
    env=env_config,
    description="A stack for managing Certbot with Route53 and S3.",
)

# Instantiate the CdkCertbotDnsRoute53 construct
CdkCertbotDnsRoute53(
    stack,
    "CertbotConstruct",
    domain_name="your-actual-domain.com", # REQUIRED: Replace with your actual domain name
    hosted_zone_id="Z1ABCD2EFGHIJ3KLMNO4", # REQUIRED: Replace with your Hosted Zone ID for the domain
    certbot_email="admin@your-actual-domain.com", # REQUIRED: Replace with your email for Certbot notifications
    # sns_topic_arn="arn:aws:sns:REGION:ACCOUNT_ID:certbot-notifications", # OPTIONAL: Uncomment and replace for SNS notifications
)

app.synth()

# To deploy this stack, navigate to the directory containing this code and run:
# cdk deploy CertbotStack --require-approval never

view raw JSON →