pepperize CDK Terraform State Backend

raw JSON →
0.1.1205 verified Sat May 09 auth: no python

Provides an AWS CDK construct to bootstrap an AWS account with an S3 bucket and DynamoDB table for use as a Terraform state backend. Version 0.1.1205, frequent releases.

pip install pepperize-cdk-terraform-state-backend
error ModuleNotFoundError: No module named 'pepperize_cdk_terraform_state_backend'
cause Package not installed or wrong Python environment.
fix
Run 'pip install pepperize-cdk-terraform-state-backend' in the correct environment.
error jsii.errors.JSIIError: ...
cause Incompatible CDK version (requires aws-cdk-lib >=2).
fix
Upgrade aws-cdk-lib to version 2.x or later.
error Resource handler returned message: "Bucket with the same name already exists"
cause S3 bucket name conflict (global namespace).
fix
Change bucket_name to a unique string, e.g., '{}-{}'.format(account_id, bucket_name).
gotcha The construct creates resources with default removal policy (DESTROY) unless overridden. Be cautious with production state.
fix Set removal_policy on the construct props to RETAIN.
gotcha Bucket name and table name must be globally unique across all AWS accounts. Duplicating names leads to deployment errors.
fix Use unique identifiers or suffix with account ID/region.
breaking Version 0.1.0 changed the import path; older versions used a different module structure.
fix Use 'from pepperize_cdk_terraform_state_backend import TerraformStateBackend'.

Deploys an S3 bucket and DynamoDB table for Terraform state.

from constructs import Construct
from aws_cdk import App, Stack
from pepperize_cdk_terraform_state_backend import TerraformStateBackend

class MyStack(Stack):
    def __init__(self, scope: Construct, id: str, **kwargs):
        super().__init__(scope, id, **kwargs)
        TerraformStateBackend(self, "Backend",
            bucket_name="my-terraform-state",
            table_name="my-terraform-lock"
        )

app = App()
MyStack(app, "MyStack")
app.synth()