Hara Gopal
Hara Gopal

Reputation: 55

how to connect to multiple aws resources using boto3?

If one needs to connect to multiple AWS resources like dynamodb, sns, ec2 etc do we need to create separate boto3 instances for each of them or are there other ways ? at the moment am doing as show below ...

ddb = boto3.resource('dynamodb', region_name='us-east-1')
sns= boto3.client('sns', region_name='us-east-1')

Upvotes: 2

Views: 1410

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269091

Yes, that is perfectly correct.

When you make a call to the service, your code would use ddb.function() or sns.function().

Also, please note that there is a difference between .resource and .client. Basically, .client mirrors the official AWS API, while .resource provides a Python object that represents a service. You can choose whichever access method you prefer.

Upvotes: 2

Related Questions