LESSON · 1 OF 5

What boto3 is

What boto3 is

boto3 is the AWS SDK for Python. Everything you can do in the AWS console or with the aws CLI you can also do from Python code: launch an EC2 instance, upload to S3, read a queue, list IAM users. It is the standard way to automate AWS from a program.

It's already installed in your lab environment. Import it like any library:

python
import boto3

Clients

A client is a thin wrapper over the AWS API for one service. You create one by naming the service:

python
s3 = boto3.client("s3")

Client methods map almost one to one onto AWS API calls and CLI commands. s3.list_buckets(), s3.create_bucket(...), and s3.put_object(...) line up with what you'd run as aws s3api list-buckets and so on. Clients return plain Python dicts, the same shape as the JSON the API sends back.

Resources

boto3 also offers a higher-level "resource" interface that wraps those same calls in objects, so you write bucket.upload_file(...) instead of passing a bucket name to every call. It reads nicely, but it covers fewer services and AWS now steers new work toward clients.

For DevOps automation, stick with clients. They cover every service, they match the CLI you already know, and every AWS example you'll find online uses them. This topic uses clients throughout.

What this node introduces

  • boto3 is the AWS SDK for Python.
  • boto3.client("s3") creates a client for a named service.
  • Clients map onto AWS API calls and return dictionaries; prefer them over the resource interface for automation.
Spin up a fresh environment and practice live.
python-devops · fresh machine · ready in under a minute