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:
import boto3
A client is a thin wrapper over the AWS API for one service. You create one by naming the service:
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.
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.
boto3 is the AWS SDK for Python.boto3.client("s3") creates a client for a named service.