How to Set Up Your Python Environment for AWS Development

Amazon Web Services (AWS) is one of the most powerful cloud platforms available, and Python is one of the most popular languages for automation, data science, and backend development. Combining the two unlocks endless possibilities — from building serverless apps to managing cloud infrastructure.

In this guide, you’ll learn how to set up your Python development environment for AWS step-by-step, so you can start coding with services like S3, Lambda, and DynamoDB in no time.


Why Use Python with AWS?

Python is AWS’s most supported language — used extensively for automation scripts, Lambda functions, data pipelines, and DevOps tooling.

Here’s why it’s a great match:

  • 🧠 Easy to learn and flexible
  • AWS SDK (boto3) provides complete API access
  • 🛠 Works seamlessly with AWS CLI and Cloud tools
  • ☁️ Ideal for serverless, data, and machine learning projects

Step 1: Prerequisites

Before setting up your environment, make sure you have the following installed:

  • Python 3.8 or higher → Check with: python --version
  • pip (Python package manager) → Check with: pip --version
  • An AWS accountSign up here if you don’t already have one.
  • Basic terminal or command prompt knowledge

Step 2: Create a Project Folder and Virtual Environment

A virtual environment keeps your dependencies isolated per project, preventing version conflicts.

  1. Create a new project folder: mkdir aws-python-dev cd aws-python-dev
  2. Create a virtual environment: python -m venv venv
  3. Activate the virtual environment:
    • On macOS/Linux: source venv/bin/activate
    • On Windows: venv\Scripts\activate

Your prompt should now show (venv) — meaning your environment is active.


Step 3: Install AWS SDK for Python (boto3)

boto3 is the official AWS SDK for Python — it allows your code to interact with AWS services.

Install it inside your virtual environment:

pip install boto3

Verify the installation:

python -m pip show boto3

Step 4: Install and Configure the AWS CLI

The AWS Command Line Interface (CLI) is a tool that lets you interact with AWS from your terminal — and it’s also how you’ll configure credentials for boto3.

1. Install the AWS CLI

pip install awscli

Or, for a system-wide installation:


2. Configure Your AWS Credentials

Run:

aws configure

You’ll be prompted for:

AWS Access Key ID [None]: <your-access-key>
AWS Secret Access Key [None]: <your-secret-key>
Default region name [None]: us-east-1
Default output format [None]: json

This creates two files:

  • Credentials: ~/.aws/credentials
  • Config: ~/.aws/config

💡 Tip: Never share these keys or upload them to GitHub — they grant access to your AWS account.


Step 5: Verify Your Setup

Run this command to confirm your AWS CLI and credentials work:

aws sts get-caller-identity

You should see your AWS account details returned in JSON format.

Example output:

{
    "UserId": "AIDAEXAMPLEID",
    "Account": "123456789012",
    "Arn": "arn:aws:iam::123456789012:user/YourUserName"
}

Step 6: Test Your Python and AWS Connection

Now, let’s use Python to connect to AWS and list your S3 buckets.

Create a file named test_aws.py and paste this code:

import boto3

# Create an S3 client
s3 = boto3.client('s3')

# List all buckets
response = s3.list_buckets()

print("Your S3 Buckets:")
for bucket in response['Buckets']:
    print(f"  - {bucket['Name']}")

Run it:

python test_aws.py

If everything is set up correctly, you’ll see a list of your S3 buckets — or an empty list if you don’t have any yet.

🎉 You’re officially ready to develop with AWS in Python!


Step 7: Secure Your Credentials

Security is crucial when developing with AWS. Follow these best practices:

  • 🔑 Use IAM roles for applications (not hardcoded credentials)
  • 🚫 Add ~/.aws/credentials to your .gitignore file
  • 🧱 Use AWS Vault or AWS SSO for credential management
  • 🧍‍♂️ Create separate users for development, testing, and production

Example environment variable setup (alternative to aws configure):

export AWS_ACCESS_KEY_ID=your-access-key
export AWS_SECRET_ACCESS_KEY=your-secret-key

Step 8: (Optional) Install AWS Toolkit in Your IDE

If you use VS Code or PyCharm, install the AWS Toolkit plugin.
It adds cloud functionality directly to your editor:

  • Browse and deploy AWS Lambda functions
  • View CloudWatch logs
  • Interact with S3 buckets
  • Configure credentials visually

👉 AWS Toolkit for VS Code


Step 9: Set Up Environment Variables (Recommended)

For better flexibility, define AWS-related environment variables in your shell or .env file.
Example .env:

AWS_REGION=us-east-1
AWS_PROFILE=default

Then use them in Python:

Then use them in Python:

import os
import boto3

session = boto3.Session(
    region_name=os.getenv("AWS_REGION")
)

s3 = session.client('s3')
print(s3.list_buckets())

Final Thoughts

You’ve just set up your Python development environment for AWS — a huge first step toward building scalable, cloud-native apps.

Here’s what you can do next:

  • 💡 Build a serverless app using AWS Lambda + API Gateway
  • 🗄 Store data using DynamoDB or RDS
  • 📦 Automate file uploads with S3
  • 📊 Collect logs using CloudWatch

With your environment ready, you’re fully equipped to explore the AWS ecosystem and bring your Python projects to the cloud.

Leave a Reply