Amazon Web Services (AWS) - Put a message on a Simple Queue Service (SQS) Queue using the AWS CLI

by
Jeremy Canfield |
Updated: April 15 2024
| Amazon Web Services (AWS) articles
This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.
If you are not familiar with AWS Simple Queue Service (SQS), check out my article Amazon Web Services (AWS) - Getting Started with Simple Queue Service (SQS).
The aws sqs list-queues command can be used to list your queues.
~]$ aws sqs list-queues
{
"QueueUrls": [
"https://queue.amazonaws.com/123456789012/my-first-queue"
]
}
Likewise, the aws sqs get-queue-url command can be used to get the URL of your queue.
~]$ aws sqs get-queue-url --queue-name my-first-queue
{
"QueueUrl": "https://queue.amazonaws.com/123456789012/my-first-queue"
}
And then the aws sqs send-message command can be used to put a message in the queue.
~]$ aws sqs send-message --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/my-first-queue --message-body "Hello World"
{
"MD5OfMessageBody": "b10a8db164e0754105b7a99be72e3fe5",
"MessageId": "e4dc96de-d654-41ae-a31c-a5b7ba2e1f3a"
}
More realistically, messages will typically be in a structured format, such as a dictionary.
aws sqs send-message --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/my-first-queue --message-body '{"foo":"hello","bar":"world"}'
Did you find this article helpful?
If so, consider buying me a coffee over at