Python AWS integrations
AWS connections in the Dashboard and every boto3 service one attribute away, from S3 to CloudWatch.
Zato provides built-in support for connecting to AWS from your Python services. Connections are configured in the Dashboard, and your code accesses them through a simple, consistent API that covers every AWS service that boto3 supports.
This approach means your services focus on business logic rather than credential handling, session management, or low-level SDK details. Zato handles all of that for you.
Creating a connection
Open the Dashboard and go to Cloud → AWS. Create a new connection and fill in your account details.
| Field | Description |
|---|---|
| Name | Any name you want to reference the connection by in your services |
| Region | The AWS region to connect to, e.g. us-east-1 or eu-central-1 |
| Access key ID | The access key ID of the IAM user or role the connection authenticates as |
| Endpoint URL | Optional. Leave empty for AWS itself, or point it at an S3-compatible store or a local AWS simulator |
| Secret access key | Set it through the connection's "Change secret access key" option after the connection is created |
Once saved, the connection becomes available to all your services by its configured name.
Basic usage
The connection is available through self.aws, and you reference it by the name you gave it in the Dashboard. Each AWS service is an attribute of the connection, so conn.s3 is the S3 client, conn.sqs is the SQS client, and so on, for every service AWS offers.
# -*- coding: utf-8 -*-
# Zato
from zato.server.service import Service
class ListInvoiceFiles(Service):
def handle(self):
# Get the connection by the name configured in Dashboard
conn = self.aws['My AWS']
# List objects in a bucket
response = conn.s3.list_objects_v2(Bucket='invoices')
# Return the object names to the caller
names = []
for item in response['Contents']:
names.append(item['Key'])
self.response.payload = {'names': names}
Everything boto3 supports
The per-service attributes are shorthand for boto3 clients - conn.s3 is the same object as conn.client('s3'). For services whose names are not valid Python attributes, or when you prefer to be explicit, use conn.client. The higher-level resource API is available through conn.resource.
# -*- coding: utf-8 -*-
# Zato
from zato.server.service import Service
class RunAnything(Service):
def handle(self):
conn = self.aws['My AWS']
# Any service by name, same as boto3.client(...)
athena = conn.client('athena')
# The resource API too, same as boto3.resource(...)
dynamodb = conn.resource('dynamodb')
table = dynamodb.Table('customers')
Clients and resources are cached per connection, so repeated access is free.
AWS services
Each page below covers one of the most commonly integrated AWS services, with complete, working examples:
- Tutorial - start here if this is your first AWS connection
- S3 - buckets, objects, presigned URLs
- EC2 - describe and manage instances
- SQS - queues, sending and receiving messages
- SNS - topics, publishing, subscriptions
- DynamoDB - tables, items, queries
- Lambda - invoking functions
- CloudWatch - metrics and logs