AWS SNS - How to get SNS topic by name

0 votes

I am working with AWS SNS to send push notifications to my app. To get a topic that I want, to send push notifications to, I need to load all topics – using SNS client function listTopics() - and check each topic to see if the ARN has the name of the topic that I'm looking for.

I think that it's a very inefficient way to get a topic ARN.  Is there a most efficient way to get this information, like a function getTopicByName?

If not, I'd like to know if ARN is immutable, and if can I store the topic ARN on my database?

Thanks.

Sep 4, 2018 in AWS by datageek
• 2,540 points
4,659 views

1 answer to this question.

0 votes

If you know the topic already exists or you don't care if it gets created, then a much more direct approach, it is simply to call CreateTopic. Given a name, CreateTopic will return the existing topic, including the ARN.

answered Sep 4, 2018 by Archana
• 4,170 points
What if you dont have createTopic permissions
It'll throw an error saying "You are unauthorized to perform this action"

Related Questions In AWS

0 votes
1 answer

how to get the list of aws services i am used in aws my account by using the lambda function

Hi@shalk, You can create a session in your ...READ MORE

answered Sep 24, 2020 in AWS by MD
• 95,460 points
2,420 views
+1 vote
3 answers

How to get ARN for s3 Bucket using aws cli .

An ARN is a non-opaque, constructible identifier, ...READ MORE

answered Aug 16, 2018 in AWS by Priyaj
• 58,100 points
5,560 views
0 votes
1 answer

How to get AWS account/service cost using CloudWatch API?

You can check this link for a ...READ MORE

answered Jul 13, 2018 in AWS by Priyaj
• 58,100 points
884 views
+1 vote
2 answers

How to use jenkinsfile to get content from AWS SQS?

You can import standard AWS SDK to ...READ MORE

answered Jul 20, 2018 in AWS by Flying geek
• 3,280 points
2,483 views
+3 votes
1 answer

How to get a Job for AWS cloud architect

A Cloud Architect is an IT specialist who is ...READ MORE

answered Sep 25, 2018 in AWS by Priyaj
• 58,100 points
608 views
0 votes
1 answer

How to get aws lambda response as an HTML page

Store the HTML markup in a variable and return ...READ MORE

answered Dec 4, 2018 in AWS by Archana
• 5,640 points
1,824 views
0 votes
1 answer

How to get AWS Bandwidth fora year?

It's very easy. Just click on your account ...READ MORE

answered Feb 12, 2019 in AWS by Archana
• 5,640 points
620 views
0 votes
2 answers

How to display just the name of files using aws s3 ls command?

aws s3 ls s3://<your_bucket_name>/ | awk '{print ...READ MORE

answered Mar 17, 2019 in AWS by anonymous
21,931 views
0 votes
1 answer

How to Restrict AWS Resource Access to a Specific IAM Role

You can use iam get-role to find the Role-Id and add ...READ MORE

answered Aug 13, 2018 in AWS by Archana
• 4,170 points
1,130 views
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