Create names topic subscribe and publish message - AWS SNS

0 votes

I have an assignment to finish which requires me to do the following:

  1. Create a named topic. 
  2. Subscribe your recipients to the topic.
  3. Publish a message on the topic.
How do I do it?
Aug 21, 2019 in AWS by Varsha
3,388 views

1 answer to this question.

0 votes

You can write a python code which will look something like this:

import boto3

# Create an SNS client
client = boto3.client(
    "sns",
    aws_access_key_id="ACCES KEY",
    aws_secret_access_key="SECRET KEY",
    region_name=us-east-2
)

topic = client.create_topic(Name="notifications")
topic_arn = topic['TopicArn']  

# Add SMS Subscribers
for number in list_of_contacts:
    client.subscribe(
        TopicArn=topic_arn,
        Protocol='sms',
        Endpoint=number  
    )

# Publish a message.
client.publish(Message="Good news everyone!", TopicArn=topic_arn)
answered Aug 21, 2019 by Hari

Related Questions In AWS

0 votes
1 answer

Python code to publish a message to AWS SNS

Hey @Dipti, you could use something like ...READ MORE

answered Aug 21, 2019 in AWS by Tara
17,590 views
0 votes
1 answer

Email notification using SNS topic and Lambda function in AWS?

Hi@akhtar, You can set notification system for your ...READ MORE

answered Apr 2, 2020 in AWS by MD
• 95,440 points
4,374 views
+1 vote
1 answer
0 votes
1 answer

AWS SNS - How to get SNS topic by name?

If you know the topic already exists ...READ MORE

answered Sep 4, 2018 in AWS by Archana
• 4,170 points
4,293 views
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,090 points
2,426 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,439 views
0 votes
1 answer

How do I publish a message on topic? - AWS SNS

Hey @Harish, follow these steps: On the navigation ...READ MORE

answered Jul 25, 2019 in AWS by Arya
1,536 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP