5

An AWS SQS queue URL looks like this:

sqs.us-east-1.amazonaws.com/1234567890/default_development

And here are the parts broken down:

Always same | Stored in env var | Always same   | ?          | Stored in env var
sqs         | us-east-1         | amazonaws.com | 1234567890 | default_development

So I can reconstruct the queue URL based on things I know except the 1234567890 part.

What is this number and is there a way, if I have my AWS creds in env vars, to get my hands on it without hard-coding another env var?

0

2 Answers 2

2

If you don't have access to the queue URL directly (e.g. you can get it directly from CloudFormation if you create it there) you can call the GetQueueUrl API. It takes a parameters of the QueueName and optional QueueOwnerAWSAccountId. That would be the preferred method of getting the URL. It is true that the URL is a well formed URL based on the account and region, and I wouldn't expect that to change at this point. It is possible that it would be different in a region like the China regions, or the Gov Cloud regions.

Sign up to request clarification or add additional context in comments.

Comments

1

The 1234567890 should be your AWS account number.

http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/ImportantIdentifiers.html

6 Comments

I suspected that the 1234567890 was something like that, but how do I get that number? Do I have to hard-code it into my env vars? Seems strange if so.
The GetUser API call, with no username will return information about the user making the call: docs.aws.amazon.com/IAM/latest/APIReference/API_GetUser.html
@JasonSwett the doc cited in the answer suggests that the fact that you are asking this question means you're planning to do something you should not do: "In your system, always store the entire queue URL as Amazon SQS returned it to you when you created the queue (for example, sqs.us-east-1.amazonaws.com/123456789012/queue2). Don't build the queue URL from its separate components each time you need to specify the queue URL in a request because Amazon SQS could change the components that make up the queue URL."
Good point @Michael - there is no guarantee that the queue names will always be built that way.
Ah, good catch. I guess that comment would make an appropriate correct answer to my question if you want to add it as an answer.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.