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,440 points
373 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,090 points

Related Questions In AWS

+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
• 56,900 points
1,553 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
• 56,900 points
153 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,160 points
234 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
• 56,900 points
69 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,560 points
139 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 in AWS by Archana
• 5,560 points
21 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 in AWS by anonymous
4,067 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,090 points
132 views