Cloud Development Kit for Terraform (CDKTF)

0.21.0 · deprecated · verified Fri Apr 10

The Cloud Development Kit for Terraform (CDKTF) allowed developers to define and provision infrastructure using familiar programming languages like Python, instead of HashiCorp Configuration Language (HCL). It provided access to the entire Terraform ecosystem, leveraging existing tooling for testing and dependency management. As of December 10, 2025, HashiCorp has officially deprecated CDKTF, ceasing maintenance and development. The project repository is archived, and no further updates, fixes, or improvements (including compatibility updates) will be made.

Warnings

Install

Imports

Quickstart

This quickstart defines an AWS S3 bucket. First, initialize a new CDKTF project with `cdktf init --template=python --providers=aws` in an empty directory. Then, replace the content of `main.py` with the code above. Ensure AWS credentials and default region are configured (e.g., via environment variables `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION`). Run `cdktf get` to generate provider bindings, then `cdktf deploy` to provision the bucket.

import os
from constructs import Construct
from cdktf import App, TerraformStack, TerraformOutput
from cdktf_cdktf_provider_aws.provider import AwsProvider
from cdktf_cdktf_provider_aws.s3 import S3Bucket

class MyStack(TerraformStack):
    def __init__(self, scope: Construct, id: str):
        super().__init__(scope, id)

        AwsProvider(self, 'Aws', region=os.environ.get('AWS_REGION', 'us-east-1'))

        bucket = S3Bucket(self, 'MyBucket',
            bucket_prefix="my-unique-cdktf-bucket-",
            tags={
                "Environment": "Development",
                "ManagedBy": "CDKTF"
            }
        )

        TerraformOutput(self, 'bucket_name', value=bucket.id)


app = App()
MyStack(app, 'my-cdktf-aws-stack')
app.synth()

view raw JSON →