When using AWS SQS, is there any reason to prefer using GetQueueUrl to building a queue url from the region, account id, and name?

amazon-sqs, amazon-web-services

Solution

I don't think you have any guarantee that the URL will have such a form. The official documentation states the `GetQueueUrl` call as the official method for obtaining queue urls. So while constructing it using the method above may be a very good guess, it may also fail at any time because Amazon can change the URL scheme (e.g. for new queues).

Problem

I have an application that uses a single SQS queue. For the sake of flexibility I would like to configure the application using the queue name, SQS region, and AWS account id (as well as the normal AWS credentials and so forth), rather than giving a full queue url. Does it make any sense to use `GetQueueUrl` to retrieve a url for the queue when I can just build it with something like the following (in ruby): ``` region = ENV['SQS_REGION'] # 'us-west-2' account_id = ENV['SQS_AWS_ACCOUNT_ID'] # '773083218405' queue_name = ENV['SQS_QUEUE_NAME'] # 'test3' queue_url = "https://sqs.#{region}.amazonaws.com/#{account_id}/#{queue_name} # => https://sqs.us-west-2.amazonaws.com/773083218405/test3 ``` Possible reasons that it might not: - Amazon might change their url format. - Others???

Original source