AWS Cloud Development Kit Core Library (v1 - Deprecated)

1.204.0 · deprecated · verified Thu Apr 16

The `aws-cdk-core` package is the foundational library for AWS Cloud Development Kit (CDK) v1. AWS CDK is an open-source software development framework for defining cloud infrastructure as code using familiar programming languages (like Python, TypeScript, Java, C#, Go). It synthesizes infrastructure definitions into AWS CloudFormation templates for deployment. Version 1 of AWS CDK officially reached end-of-support on June 1, 2023, and this package is no longer maintained or updated.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a basic AWS CDK v1 application in Python, define an S3 bucket, and synthesize it into a CloudFormation template. It assumes the AWS CDK CLI (Node.js based) is already installed globally. Replace `CDK_DEFAULT_ACCOUNT` and `CDK_DEFAULT_REGION` with your AWS account ID and desired region, respectively. The `cdk bootstrap` command is typically a one-time setup per AWS account and region to provision resources required by the CDK.

# 1. Initialize a new CDK project (requires Node.js and 'aws-cdk' CLI installed)
# mkdir my-cdk-app
# cd my-cdk-app
# cdk init app --language python

# 2. Install dependencies
# pip install -r requirements.txt

# 3. Define a simple stack (in my_cdk_app/my_cdk_app_stack.py)
from aws_cdk import core as cdk
from aws_cdk import aws_s3 as s3

class MyCdkAppStack(cdk.Stack):
    def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        s3.Bucket(self, "MyFirstBucket",
                  versioned=True,
                  bucket_name=f"my-first-cdk-bucket-{cdk.Aws.ACCOUNT_ID}")

# 4. Instantiate the app and stack (in app.py)
import os

app = cdk.App()
MyCdkAppStack(app, "MyCdkAppStack",
              env=cdk.Environment(
                  account=os.environ.get('CDK_DEFAULT_ACCOUNT', ''),
                  region=os.environ.get('CDK_DEFAULT_REGION', 'us-east-1'))
             )
app.synth() # Generates CloudFormation template

# 5. Deploy (from terminal)
# cdk bootstrap  # First-time setup per AWS account/region
# cdk deploy MyCdkAppStack

view raw JSON →