aws-cdk.aws-ec2
The CDK Construct Library for AWS::EC2
What it is and what it does
aws-cdk.aws-ec2 is the EC2 construct library for AWS CDK v1, a framework for defining cloud infrastructure using Python code. It abstracts EC2 networking primitives—VPCs, subnets (public, private-with-NAT, and isolated), availability zones, security groups, and instances—into reusable constructs that generate CloudFormation templates. You define your infrastructure declaratively, and CDK synthesizes it into deployable AWS resources.
The package is part of the broader AWS CDK ecosystem and depends on core CDK modules (aws-cdk.core, aws-cdk.cx-api, constructs) plus related AWS service libraries (IAM, KMS, S3, CloudWatch, Logs, SSM). It is designed for developers building cloud applications who want to express infrastructure in Python rather than writing CloudFormation YAML or JSON directly.
Use it for:
- Define a VPC with public and private subnets, then launch EC2 instances into them as part of a CDK stack.
- Create VPC endpoints and configure subnet selection by availability zone and subnet type for high-availability deployments.
- Provision security groups and network ACLs to control inbound and outbound traffic to EC2 resources.
- Integrate EC2 networking with other AWS services by specifying VPC and subnet configuration in a single CDK app.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides AWS CDK constructs for defining EC2 networking and compute resources (VPCs, subnets, instances) as infrastructure-as-code in Python.
No, unless you are maintaining an existing CDK v1 codebase. AWS CDK v1 reached end-of-support on 2023-06-01 and is no longer being updated. New projects should use AWS CDK v2 instead. If you are already on v1, plan a migration to v2 rather than starting new work with this package.
Install
aws-cdk-aws-ec2 on PyPI
pip
pip install aws-cdk-aws-ec2uv
uv add aws-cdk-aws-ec2poetry
poetry add aws-cdk-aws-ec2Installing aws-cdk.aws-ec2
Before you install
Low install friction with a pure-Python wheel. However, this is AWS CDK v1, which reached end-of-support on 2023-06-01 and is no longer being updated; users should migrate to AWS CDK v2.
License in practice
Licensed under Apache-2.0 (permissive), allowing commercial and private use with minimal restrictions.
Quickstart
pip install aws-cdk.aws-ec2
import aws_cdk.aws_ec2 as ec2
vpc = ec2.Vpc(self, "VPC")
Requires Python 3.7 or later; AWS CDK v1 reached end-of-support on 2023-06-01.
Verify before relying
- Whether v1-to-v2 migration tooling or automated upgrade paths are available to ease the transition.
- Current security posture and whether v1 receives any backported security patches post-EOL.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (~=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 15 — aws-cdk.aws-cloudwatch, aws-cdk.aws-iam, aws-cdk.aws-kms, aws-cdk.aws-logs, aws-cdk.aws-s3-assets, aws-cdk.aws-s3, aws-cdk.aws-ssm, aws-cdk.cloud-assembly-schema, aws-cdk.core, aws-cdk.cx-api, aws-cdk.region-info, constructs, jsii, publication, typeguard |
| Maintenance | actively maintained — 1,152 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 195,566/month — #9,812 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: aws_cdk.aws_ec2-1.204.0-py3-none-any.whl
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
aws-cdk.aws-batchDefines AWS Batch infrastructure (compute…
permissive · top 15,000 on PyPI
aws-cdk.aws-ecsProvides AWS CDK constructs for defining and…
permissive · top 15,000 on PyPI
aws-cdk.aws-efsProvides CDK constructs to define Amazon EFS…
permissive · top 15,000 on PyPI
aws-cdk.aws-neptune-alphaProvides AWS CDK constructs for defining and…
permissive · top 15,000 on PyPI
aws-cdk.aws-servicediscoveryProvides AWS CDK constructs for defining and…
permissive · top 15,000 on PyPI
cdk-aurora-globaldatabaseProvides AWS CDK constructs to deploy Amazon…
permissive · top 15,000 on PyPI
ec2-metadataQueries the EC2 Instance Metadata Service v2 to…
permissive · top 5,000 on PyPI
aws-cdk.aws-fsxProvides AWS CDK constructs for defining and…
permissive · top 15,000 on PyPI
aws-cdk.aws-route53Provides Python constructs to define and manage…
permissive · top 15,000 on PyPI
aws-cdk.aws-redshift-alphaDefines AWS Redshift clusters and database…
permissive · top 15,000 on PyPI