Created
July 14, 2020 17:27
-
-
Save piyusht007/28b1990b47c09f39e5df4e4d20d897a7 to your computer and use it in GitHub Desktop.
Amazon SNS - Publish message to a topic using python boto3
This file contains 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
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