Skip to content

Instantly share code, notes, and snippets.

@robert-b-clarke
Created June 27, 2014 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robert-b-clarke/02c21ab05b76749f3da8 to your computer and use it in GitHub Desktop.
Save robert-b-clarke/02c21ab05b76749f3da8 to your computer and use it in GitHub Desktop.
Publish SNS messages in Python3 using botocore
import botocore.session
# establish a session and set credentials
sesh = botocore.session.get_session()
sesh.set_credentials(access_key='YOUR_KEY', secret_key='YOUR_SECRET')
#get SNS service and set endpoint
sns = sesh.get_service('sns')
endpoint = sns.get_endpoint('eu-west-1') #or another AWS region
#set up a Publish call and execute it
op = sns.get_operation('Publish')
http_response, response_data = op.call(topic_arn='TOPIC_ARN', subject='test', message='hello', endpoint=endpoint)
@jplazcano87
Copy link

am getting this error

AttributeError: 'Session' object has no attribute 'get_service'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment