AWS is managed with APIs, not clicks. This module shows how Python automates the cloud with Boto3 (read-only here), plus an intro to Infrastructure as Code with AWS CDK.
The scripts only read from AWS (list S3 buckets, list EC2 instances). Nothing is created, modified, or deleted unless you choose to run the optional create helpers.
AWS credentials configured locally:
aws configure # or set AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_DEFAULT_REGIONpython3 -m venv venv
source venv/bin/activate
pip install -r requirements.txts3_utilities.py—AWSUtilsclass: list buckets, optional create/uploadaws_resource_report.py— list S3 + EC2 and writeaws_report.jsoncdk_demo/— an Infrastructure-as-Code example: a CDK stack with one S3 bucket
python aws_resource_report.py
python s3_utilities.pyThese call real AWS APIs and need valid credentials — without them you'll get a
NoCredentialsError / ClientError, which is expected.
Boto3 is great for reading state, reporting, and one-off automation. For
creating/updating/deleting infrastructure, prefer IaC tools (Terraform,
CloudFormation, CDK) — they track state and are repeatable. See cdk_demo/.
Write an AWS resource report:
- Create a
boto3.Session()and an S3 client, and list all bucket names. - List EC2 instances (instance id + state).
- Print the report and save it to
aws_report.json. - Bonus: wrap the calls in
try / except (BotoCoreError, ClientError)so missing credentials print a friendly message instead of a traceback.
Read-only only — don't create or delete resources.