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
587 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
1,882 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 6 days ago in AWS by MD
• 9,570 points
18 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,150 points
780 views
0 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
• 57,530 points
454 views
+13 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,400 points
425 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
279 views
0 votes
1 answer