Created
February 12, 2014 14:00
-
-
Save tfhartmann/8956049 to your computer and use it in GitHub Desktop.
Example script on how to publish a message to an AWS SNS Queue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!//opt/boxen/homebrew/bin/python | |
import boto.sns | |
import json | |
REGION = 'us-west-2' | |
TOPIC = '<ARN>' | |
URL = '<Body of Message in this example I used a url>' | |
conn = boto.sns.connect_to_region( REGION ) | |
pub = conn.publish( topic = TOPIC, message = URL ) | |
This page is quite high on google search results so here's an example on how to do this with Boto3
This requires that you have set AWS credentials to your ~/.aws/credentials and the default region in ~/.aws/config
import boto3
client = boto3.client('sns')
response = client.publish(
TopicArn='<your topic arn>',
Message='<your message>'
)
print("Response: {}".format(response))
Added region name too
`
import boto3
client = boto3.client('sns',, region_name='us-east-1')
response = client.publish(
TopicArn='',
Message=''
)
print("Response: {}".format(response))
`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For those seeing this post years later -- the boto3 approach is much different.