This section contains all the CDK code examples written in Python. For more information on using the CDK in Python, please see the Developer Guide.
- Ensure CDK is installed
$ npm install -g aws-cdk
- Create a Python virtual environment
$ python3 -m venv .venv
- Activate virtual environment
On MacOS or Linux
$ source .venv/bin/activate
On Windows
% .venv\Scripts\activate.bat
- Install the required dependencies.
$ pip install -r requirements.txt
- Synthesize (
cdk synth
) or deploy (cdk deploy
) the example
$ cdk deploy
$ cdk destroy
Example | Description |
---|---|
api-cors-lambda | Shows creation of Rest API (GW) with an /example GET endpoint, with CORS enabled |
application-load-balancer | Using an AutoScalingGroup with an Application Load Balancer |
appsync-graphql-dynamodb | Creating a single GraphQL API with an API Key, and four Resolvers doing CRUD operations over a single DynamoDB |
classic-load-balancer | Using an AutoScalingGroup with a Classic Load Balancer |
custom-resource | Shows adding a Custom Resource to your CDK app |
dockerized-app | Deploys a containerized app into 3 tiers with userdata in an autoscaling group |
ecs-cluster | Provision an ECS Cluster with custom Autoscaling Group configuration |
ecs-load-balanced-service | Starting a container fronted by a load balancer on ECS |
ecs-service-with-task-placement | Starting a container ECS with task placement specifications |
ecs-service-with-advanced-alb-config | Starting a container fronted by a load balancer on ECS with added load balancer configuration |
ecs-service-with-task-networking | Starting an ECS service with task networking, allowing ingress traffic to the task but blocking for the instance |
fargate-load-balanced-service | Starting a container fronted by a load balancer on Fargate |
fargate-service-with-autoscaling | Starting an ECS service of FARGATE launch type that auto scales based on average CPU Utilization |
lambda-cron | Running a Lambda on a schedule |
lambda-layer | Running a Lambda with a lambda layer |
lambda-s3-trigger | S3 trigger for Lambda |
rds | Creating a MySQL RDS database inside its dedicated VPC |
s3-object-lambda | Creating an S3 Object Lambda and access point |
stepfunctions | A simple StepFunctions workflow |
url-shortener | Demo from the Infrastructure is Code with the AWS CDK AWS Online Tech Talk |
ec2-instance | Create EC2 Instance in new VPC with Systems Manager enabled |
serverless-backend | Create a serverless backend with API Gateway, Lambda, S3, DynamoDB, and Cognito |
vpc-ec2-local-zones | Create a VPC with public and private subnets in AWS Local Zones |