Are Boto3 Resources and Clients Equivalent? When Use One or Other?

Solution 1:

Resources are just a resource-based abstraction over the clients. They can't do anything the clients can't do, but in many cases they are nicer to use. They actually have an embedded client that they use to make requests. The downside is that they don't always support 100% of the features of a service.

Solution 2:

Always create a resource. It has the important methods you will need, such as Table. If you happen to need a client object, it's there ready for use, just ask for .meta.client:

import boto3
dynamodb = boto3.resource(service_name='dynamodb', endpoint_url='http://localhost:8000')
try:
    dynamodb.create_table(...)
except dynamodb.meta.client.exceptions.ResourceInUseException:
    logging.warn('Table already exists')
table = dynamodb.Table(table_name)
response = table.get_item(...)