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 in AWS by Varsha
20 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 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 in AWS by Tara
30 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,090 points
372 views
0 votes
1 answer

AWS SNS Topic subscription filter account limit

I guess you can only have 100 ...READ MORE

answered Oct 24, 2018 in AWS by Priyaj
• 56,900 points
286 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
• 56,900 points
216 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,380 points
205 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 in AWS by Arya
56 views
0 votes
1 answer