Skip to content

Instantly share code, notes, and snippets.

@piyusht007
Created July 14, 2020 17:27
Show Gist options
  • Save piyusht007/28b1990b47c09f39e5df4e4d20d897a7 to your computer and use it in GitHub Desktop.
Save piyusht007/28b1990b47c09f39e5df4e4d20d897a7 to your computer and use it in GitHub Desktop.
Amazon SNS - Publish message to a topic using python boto3
import boto3
client = boto3.client('sns')
topics = client.list_topics()
print(topics)
topicArn = topics['Topics'][0]['TopicArn']
print(topicArn)
response = client.publish(
TopicArn=topicArn,
Message='Cricket is Live!!',
Subject='PYTHON',
MessageAttributes={
'customer_interests': {
'DataType': 'String',
'StringValue': 'cricket',
}
}
)
print(response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment