Most people learn AWS SQS by clicking through the management console. That works until the day you need to automate something, run a script in CI, or manage queues across dozens of environments without touching a mouse. The command line is where SQS gets serious, and this tutorial walks through exactly how to get there using the AWS CLI inside Cloud9.
This is the CLI overview lesson from the Mastering AWS SQS course. The goal is simple: spin up a Cloud9 environment, enter your first SQS commands, and understand what each one does before moving on to queue attributes, tagging, and message deletion in the next session.
What You’ll Walk Out With
- A working AWS Cloud9 environment configured for SQS CLI work
- The list-queues command and why there’s a short delay after queue creation before it shows results
- How to create named queues from the terminal using create-queue
- Queue prefix filtering so you can slice a large list down to exactly what you need
- The full send-message flow including what a successful response looks like
- How to verify messages arrived using both the CLI and the AWS Management Console
- What a receipt handle is and why you need it before you can delete a message
- Not sure which cloud skill to build first? Take the free quiz at finder.platformproof.com to find your starting point.
Why Cloud9 for SQS CLI Work
AWS Cloud9 is a cloud-based IDE that includes a terminal pre-configured with the AWS CLI. That matters here because the CLI is already authenticated to your AWS account when you open the terminal inside Cloud9. You skip the entire local setup process: no credential files, no profile configuration, no region environment variables to set by hand. The environment just works.
Before running any SQS commands, you need a Cloud9 environment. To create one: open the Cloud9 service from the AWS console, click Create environment, give it a name (the course uses “sqs”), leave all defaults in place, and confirm. The environment takes a minute or two to provision. Once it’s ready, you get a split-screen editor and an embedded terminal at the bottom. All the commands in this tutorial go in that terminal.
One important note before you start: Cloud9 environments run on EC2 instances. If you walk away and forget to stop or delete the environment, you will be charged for the compute time. The course recommends deleting environments you are not actively using, or at minimum stopping the underlying EC2 instance from the EC2 console.
Your First Command: List Queues
The first SQS CLI command you will run is aws sqs list-queues. On a fresh account with no queues created yet, this returns nothing, which is the expected result. It confirms the CLI is connected and authenticated correctly. If you see an error here, something is wrong with your Cloud9 setup or IAM permissions, not with the command itself.
The full syntax is straightforward:
aws sqs list-queues
Once you have queues in your account, this command returns a list of queue URLs. SQS identifies queues by URL rather than by name, which surprises people coming from other services. When you create a queue, AWS assigns it a URL in the format https://sqs.REGION.amazonaws.com/ACCOUNT-ID/QUEUE-NAME. That URL is what you pass to every subsequent command: send-message, receive-message, delete-message, and more. Keep the URLs handy as you create queues.
Creating Queues from the Terminal
The create-queue command takes one required parameter: the queue name. The syntax is:
aws sqs create-queue –queue-name new-queue
When the command succeeds, the CLI returns a JSON object containing the queue URL. That URL is your confirmation that the queue exists. No URL in the response means something went wrong. In the course, the queue is named “new-queue” to start, then the lesson creates five more queues to demonstrate prefix filtering: new-q1, new-q2, old-queue, old-q1, and old-q2. Creating all six gives you a meaningful set to work with.
One thing the video is upfront about: there is a short propagation delay between when you create a queue and when it shows up in list-queues. You might create a queue, immediately run list-queues, and not see it yet. The course handled this by creating all six queues first, then waiting roughly 30 seconds before listing. After the wait, all six appeared correctly.
Queue naming has a few rules worth knowing. Names can be up to 80 characters. Standard queue names can contain alphanumeric characters, hyphens, and underscores. FIFO queue names must end in .fifo. If you try to create a queue with the same name as an existing queue but with different attributes, SQS returns an error instead of overwriting the existing queue. Naming thoughtfully from the start saves you cleanup work later.
Filtering Queues by Prefix
Once you have six queues in the account, list-queues returns all six. In a production account with hundreds of queues, an unfiltered list is not useful. The –queue-name-prefix flag lets you filter the list to only queues whose names start with a given string.
From the course, with the six queues created (three starting with “new” and three starting with “old”), this command:
aws sqs list-queues –queue-name-prefix new
returns only new-queue, new-q1, and new-q2. The three old queues are excluded. This is exactly the kind of filtering that makes CLI operations manageable in real environments. If you organize queue names by environment (prod-, staging-, dev-) or by service (payments-, notifications-, orders-), prefix filtering lets you list just the queues you need without scripting any parsing logic.
Sending a Message from the CLI
Sending a message requires two parameters: the queue URL and the message body. The syntax is:
aws sqs send-message –queue-url QUEUE_URL –message-body “your message here”
In the course, the first message sent to new-q1 has the body “hot cross buns” as a quick test. The second message, sent to the new-queue, has the body “today’s date is ?” to demonstrate that the message body is freeform text. When a message is accepted, the CLI returns two fields: a MessageId (a UUID assigned by SQS) and an MD5OfMessageBody (a hash of the message content). Both confirm the message was accepted.
The queue URL to use is the one returned when you created the queue. If you lost it, run list-queues with the appropriate prefix to retrieve it. Copying the URL directly from the terminal output reduces the chance of typos, which will cause a QueueDoesNotExist error rather than a helpful message.
Message bodies can hold up to 256 KB of text. For larger payloads, the common pattern is to put the data in S3 and send only an S3 reference in the message body. The SQS Extended Client library handles this pattern automatically if you prefer a library approach over doing it by hand.
Not sure which cloud or tech skill to build first?
The free quiz at finder.platformproof.com matches your current background to the skill with the clearest path to your first $3,000 online.
Verifying Messages in the AWS Console
After sending messages from the CLI, the course switches to the AWS Management Console to verify they arrived. Opening the SQS service, clicking the queue, then clicking View messages and hitting Start polling shows the messages waiting in the queue. The second message body, “today’s date is ?”, was visible in the console, confirming end-to-end delivery from CLI command to queue storage.
The lesson ran into a region mismatch that is worth learning from. The CLI environment was configured for the ap-southeast-1 region (Singapore), while the console was initially opened showing us-east-1 (Northern Virginia). The queues were invisible in us-east-1 because they do not exist there. After switching the console region to ap-southeast-1, all six queues appeared. SQS queues are regional resources. They exist only in the region where they were created. This is one of the most common points of confusion for people new to AWS: creating something in one region and then looking for it in another.
To check which region your CLI is targeting, run aws configure get region from the terminal. If the region is wrong, you can set it with aws configure set region us-east-1 or by passing –region as a flag on individual commands. Cloud9 environments inherit the region of the account they are launched in, which is why the course ended up in Singapore instead of Virginia.
Receiving Messages and the Receipt Handle
The receive-message command retrieves one or more messages from a queue. The syntax is:
aws sqs receive-message –queue-url QUEUE_URL
The response includes the message body, the MessageId, and a ReceiptHandle. The receipt handle is a long, unique token that SQS assigns each time a message is delivered to a consumer. It is not the message ID. It is a temporary token tied to this specific delivery attempt, and it expires when the queue’s visibility timeout period ends.
The receipt handle is what you pass to delete-message to permanently remove the message from the queue after you have processed it. If you do not delete the message, SQS makes it visible again after the visibility timeout and another consumer can pick it up. This at-least-once delivery behavior is by design for standard queues. It protects against message loss if a consumer crashes mid-processing but requires your application to handle the same message arriving more than once. The next tutorial in the series covers delete-message in full.
Honest Drawbacks to Know Before Going Further
SQS is a reliable, scalable service, but it has friction points that the documentation does not always surface up front. Here are the ones worth knowing before you build anything on top of what this lesson covers.
Standard queues do not guarantee ordering. Messages can arrive out of order. If order matters for your use case, you need a FIFO queue, which ends in .fifo and has a lower throughput limit than a standard queue.
Standard queues can deliver a message more than once. At-least-once delivery is the default. Your consumer code needs to be idempotent, meaning running it twice on the same message should produce the same result as running it once. FIFO queues provide exactly-once processing but cost more and have stricter naming and throughput constraints.
The maximum message size is 256 KB. Large files, images, or structured data objects usually need to live in S3 with only a reference in the SQS message. Building around this limit from the start avoids painful refactors later.
Queue creation has a propagation delay. As the video demonstrates, you create a queue and it does not immediately appear in list-queues. In automated scripts, you may need a short sleep or retry loop before assuming the queue is ready to use.
The CLI syntax uses hyphens for multi-word flags, which differs from SDKs that use camelCase. –queue-name-prefix in the CLI becomes QueueNamePrefix in the SDK. Keeping both in mind reduces confusion when you move from manual CLI work to code.
What the Next Tutorial Covers
The course picks up from this session with the following topics: sending additional messages to test queue behavior under load, creating queues with attributes (like custom visibility timeouts or message retention periods), listing those attributes, tagging queues for cost allocation and organization, deleting individual messages using the receipt handle, and deleting entire queues when they are no longer needed. Each of those operations builds on the commands covered here, so the foundation matters.
Find Your X
AWS skills, SQS included, have a real market. But knowing which cloud skill to prioritize depends on where you are starting from and what kind of work you want to do. The free quiz at finder.platformproof.com takes five minutes and gives you a clear starting point based on your current background, not a generic list of every AWS service that exists.
Frequently Asked Questions
What is AWS SQS?
Amazon Simple Queue Service (SQS) is a fully managed message queuing service. It lets different parts of an application send and receive messages asynchronously without being directly connected to each other. One service puts a message on a queue; another service reads it and processes it when ready. The queue acts as a buffer between the two.
Why use the CLI instead of the AWS Console for SQS?
The console is useful for exploration and one-off tasks. The CLI is necessary for automation. If you want to create queues as part of a deployment script, run integration tests that set up and tear down queues, or manage queues across many accounts, the CLI is the right tool. Scripts that use CLI commands are also repeatable and reviewable in version control in a way that console click-throughs are not.
Do I need Cloud9 to use the AWS CLI with SQS?
No. Cloud9 is convenient because the CLI comes pre-configured with your account credentials. You can run every command in this tutorial from your local terminal as long as you have the AWS CLI installed and configured with aws configure. The course uses Cloud9 to reduce setup friction, especially for learners who have not configured local credentials before.
Why does SQS use URLs to identify queues instead of just names?
Queue URLs encode both the account ID and the region, which makes them globally unambiguous. Two different AWS accounts could each have a queue named “orders,” but their URLs are different because the account IDs differ. Using URLs as identifiers also means you can construct the URL from known parts without making an API call, which reduces overhead in high-throughput systems.
What is a receipt handle and is it the same as the message ID?
No, they are different. The message ID is assigned when a message is first sent to the queue and stays the same for the life of the message. The receipt handle is a temporary token assigned each time a message is delivered to a consumer. If the same message is delivered twice (because the first consumer did not delete it before the visibility timeout expired), each delivery gets a different receipt handle. You must use the receipt handle, not the message ID, to delete a message.
How long does it take for a newly created queue to appear in list-queues?
SQS documentation does not give a specific number, but in practice the delay is usually under 60 seconds. The video demonstrated this by creating all six queues first, pausing briefly, and then running list-queues to confirm they all appeared. In automated scripts, a short wait or a retry loop is safer than assuming the queue is immediately visible after creation.
Can I filter the queue list to show only certain queues?
Yes, using the –queue-name-prefix flag with aws sqs list-queues. This filters the results to queues whose names begin with the prefix you specify. There is no wildcard or suffix filter in the CLI itself. If you need more complex filtering, pipe the output to a tool like jq or grep in your shell.
What is the difference between standard and FIFO queues in SQS?
Standard queues offer maximum throughput, best-effort ordering, and at-least-once delivery. Messages may arrive out of order, and the same message may be delivered more than once. FIFO queues guarantee that messages are processed in the exact order they were sent and that each message is delivered exactly once. FIFO queues have a lower maximum throughput and require queue names to end in .fifo. Choose standard unless ordering or exactly-once processing is a hard requirement.
Read Next
If you want a broader picture of what SQS is and where it fits in the broader AWS service landscape before going deeper into CLI commands, the foundational overview covers the concepts behind message queuing, how SQS compares to alternatives, and when you would reach for it over other messaging services.
What Is AWS SQS? How Amazon’s Most Popular Cloud Service Works
Sources
- Mastering AWS SQS course, CLI overview lesson (video: XS2EXJCNIR0)
- AWS CLI Command Reference for aws sqs: docs.aws.amazon.com/cli/latest/reference/sqs/
- Amazon SQS Developer Guide: docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/
- AWS Cloud9 User Guide: docs.aws.amazon.com/cloud9/latest/user-guide/
Related Reading
- How To Make Money With Email Marketing: A Beginner's Complete Overview
- Skool | How To Make Your First $100 In MRR With Skool
- How to Make Your First $100 Online with This Simple 3-Step Process
- How to Make Your First $1,000 Online (No Hype, Just Strategy)
Helping 1 million working adults make their first $3,000 online with the skills they already have. Alston Godbolt, Platform Proof.