LinuxCommandLibrary

aws-sqs

Manage Amazon Simple Queue Service (SQS) queues

TLDR

List all availables queues

$ aws sqs list-queues
copy

Display the URL of a specific queue
$ aws sqs get-queue-url --queue-name [queue_name]
copy

Create a queue with specific attributes from a file in JSON format
$ aws sqs create-queue --queue-name [queue_name] --attributes [file://path/to/attributes_file.json]
copy

Send a specific message to a queue
$ aws sqs send-message --queue-url https://sqs.[region].amazonaws.com/[queue_name] --message-body "[message_body]" --delay-seconds [delay] --message-attributes [file://path/to/attributes_file.json]
copy

Delete the specified message from a queue
$ aws sqs delete-message --queue-url [https://queue_url] --receipt-handle [receipt_handle]
copy

Delete a specific queue
$ aws sqs delete-queue --queue-url https://sqs.[region].amazonaws.com/[queue_name]
copy

Delete all messages from the specified queue
$ aws sqs purge-queue --queue-url https://sqs.[region].amazonaws.com/[queue_name]
copy

Enable a specific AWS account to send messages to queue
$ aws sqs add-permission --queue-url https://sqs.[region].amazonaws.com/[queue_name] --label [permission_name] --aws-account-ids [account_id] --actions SendMessage
copy

SYNOPSIS

aws sqs <subcommand> [--queue-url <value>] [--region <value>] [--output <json|text|table>] [AWS CLI global options]

PARAMETERS

--queue-url
    URL of the Amazon SQS queue (required for most operations)

--region
    AWS Region (e.g., us-east-1); overrides config

--output
    Output format: json|text|table|yaml|yaml-stream

--debug
    Turn on debug logging

--endpoint-url
    Override default endpoint URL (for localstack testing)

--cli-read-timeout
    Max CLI read timeout in seconds

--cli-connect-timeout
    Max CLI connect timeout in seconds

--no-verify-ssl
    Disable SSL certificate verification

--message-body
    Body of the message to send (create/send-message)

--wait-time-seconds
    Long polling wait time (receive-message)

--max-number-of-messages
    Max messages to receive (1-10)

--visibility-timeout
    Invisibility duration for received messages

--attributes
    Queue/message attributes as JSON map

--cli-input-json
    Perform operation using JSON input

--generate-cli-skeleton
    Print JSON skeleton for input

DESCRIPTION

The aws sqs command is part of the AWS Command Line Interface (CLI), a unified tool to manage AWS services. Specifically, it provides operations for Amazon Simple Queue Service (SQS), a fully managed message queuing service that enables decoupling and scaling of microservices, distributed systems, and serverless applications.

SQS supports standard queues for high-throughput at-least-once delivery and FIFO queues for exactly-once processing with ordering. Use aws sqs to create/delete queues, send/receive/delete messages, list queues, set/get attributes (like visibility timeout, message retention), purge queues, and manage access policies, dead-letter queues, and tags.

Requires AWS account credentials (via aws configure, environment variables, or IAM roles). Outputs JSON by default; supports text/table. Ideal for scripts, automation, DevOps workflows. Handles long polling, batch operations for efficiency. Note: SQS charges per request/API call; monitor via CloudWatch.

CAVEATS

Requires AWS CLI installed/configured with credentials and SQS IAM permissions. Not all options apply to every subcommand; check aws sqs <subcommand> help. Incurs AWS costs per API call. FIFO queues have stricter limits (300 msg/sec). Messages up to 256KB; use S3 for larger.

COMMON SUBCOMMANDS

create-queue, delete-queue, list-queues, send-message, receive-message, delete-message, get-queue-attributes, set-queue-attributes, purge-queue, send-message-batch

EXAMPLE USAGE

aws sqs create-queue --queue-name my-queue
aws sqs send-message --queue-url https://sqs.us-east-1.amazonaws.com/... --message-body 'Hello'
aws sqs receive-message --queue-url https://... --max-number-of-messages 1

HISTORY

Amazon SQS launched 2006. AWS CLI v1 released 2013 with sqs support; v2 (2020) improved performance/binary. Evolving with features like high-throughput mode (2022), message systems V2.

SEE ALSO

aws sns(1), aws lambda(1), aws cloudwatch(1), jq(1)

Copied to clipboard