Reputation: 7986
I have an SNS topic on AWS, can I connect to it from my local computer using boto3?
I can't find the right doc to clear this up.
Upvotes: 1
Views: 2457
Reputation: 390
As stated in the comments, you'll need to have proper permissions as well as the proper credentials. You can set up the credentials locally using awscli which you should be able to install via pip
pip install awscli
See this guide for installation.
When you configure awscli, you'll set up a credentials file located at ~/.aws/credentials
. By default, this file will be used by Boto3 to authenticate.
aws configure
Note that this will store the AWS Access Key ID and Secret Access Key on your machine. It's best not to do this with your root account, but to make a secondary user for this purpose.
Once this is set up, connecting to AWS SNS via Boto3 will be straightforward (assuming that the linked credentials have access to SNS on your account.
import boto3
client = boto3.client('sns')
Alternatively, if you'd prefer, you can create the Boto3 client with your access key and secret access key directly.
import boto3
client = boto3.client(
'sns',
aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_KEY
)
If you have permissions issues still, then it is likely that the linked credentials don't have access to SNS. You can modify permissions through the AWS console by going to IAM and ensuring that the user you've connected has sufficient privileges.
Upvotes: 3