Setting Up Our Development Environment for the AWS CDK (Python) - krdheeraj51/aws-labs GitHub Wiki

Let's walk through setting up the AWS CDK environment for Python development. Follow these steps for a smooth configuration:

1. Install Node.js

The AWS CDK requires Node.js to run. Follow these steps to install it:

  • Download and Install Node.js:

    • Go to the Node.js official website.
    • Download the LTS (Long Term Support) version suitable for your operating system.
    • Follow the installation instructions provided on the website.
  • Verify Node.js Installation:

node --version
npm --version

2. Install and Configure the AWS CLI (if not already done)

If you haven't already installed and configured the AWS CLI, follow these instructions:

  • Download and Install AWS CLI:

  • For Windows, macOS, or Linux, refer to the AWS CLI installation guide.

  • Configure AWS CLI: After installation, configure your AWS credentials:

aws configure

Enter your AWS Access Key ID, Secret Access Key, region, and output format when prompted.

3. Install Python and pip (if not already done)

  1. Check Python Version:
python3 --version # Or just 'python' on some systems
  1. Check pip Version:
pip3 --version # Or just 'pip' on some systems

Note: If Python or pip are not installed, download and install them from https://www.python.org/ before proceeding. Ensure you are using Python 3.6 or later. pip is usually included with Python installations.

4. Set Up a Virtual Environment (Recommended)

It's highly recommended to use a virtual environment to manage your Python dependencies.

  1. Create a Virtual Environment:
python3 -m venv .venv # Creates a virtual environment named '.venv'
  1. Activate the Virtual Environment:
  • Linux/macOS:
    source .venv/bin/activate
    
  • Windows:
    .venv\Scripts\activate
    

You should see the virtual environment name (e.g., .venv) in your terminal prompt, indicating it's active.

5. Install the AWS CDK Package (Python)

  1. Install the AWS CDK package within the activated virtual environment:
pip install aws-cdk-lib constructs
  1. Verify the Installation of CDK CLI: Install CDK globally using npm:
npm install -g aws-cdk
  1. Check CDK Version:
cdk --version

This command should print the installed version of the CDK.

6. CDK Project Setup (Python)

When you initialize a new CDK project, you'll specify Python as the language. The CDK CLI will set up the necessary files and folders for you.

mkdir my-cdk-project # Create a directory for your project (optional)
cd my-cdk-project
cdk init app --language python

After running these commands, you will have a basic structure for your CDK application in Python.