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 <api-action> [<parameters>] [<global-options>]

Examples:
aws sqs create-queue --queue-name MyNewQueue
aws sqs send-message --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue --message-body "Hello SQS!"
aws sqs receive-message --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue --max-number-of-messages 1
aws sqs list-queues

PARAMETERS

send-message
    Sends a message to a specified SQS queue. Requires --queue-url and --message-body.

receive-message
    Retrieves messages from an SQS queue. Commonly used with --queue-url and --max-number-of-messages.

create-queue
    Creates a new SQS queue. Requires --queue-name and supports optional attributes like --attributes.

delete-queue
    Deletes a specified SQS queue. Requires --queue-url. Be cautious, as this operation is irreversible.

list-queues
    Lists existing SQS queues in the current region or optionally filtered by a prefix using --queue-name-prefix.

get-queue-url
    Retrieves the URL of an SQS queue given its name. Requires --queue-name.

get-queue-attributes
    Retrieves one or more attributes of a queue. Requires --queue-url and optional --attribute-names.

set-queue-attributes
    Sets the attributes of an existing queue. Requires --queue-url and --attributes.

DESCRIPTION

The "aws sqs" command is a core subcommand of the AWS Command Line Interface (CLI), a unified tool to manage your Amazon Web Services. It allows users to interact directly with the Amazon Simple Queue Service (SQS) from their terminal. SQS is a fully managed message queuing service that enables you to decouple and scale microservices, distributed systems, and serverless applications.

Through various API actions, "aws sqs" provides comprehensive control over SQS queues, including creating and deleting queues, listing available queues, sending and receiving messages, changing queue attributes, and managing message visibility timeouts. It's an essential tool for developers and administrators to automate SQS operations, debug queue behavior, and integrate SQS functionalities into scripts or applications without needing to write code against the AWS SDKs.

CAVEATS

The "aws sqs" command, as part of the AWS CLI, requires the AWS CLI to be installed and properly configured with valid AWS credentials (e.g., using aws configure) and a default region. Operations are subject to IAM permissions associated with the configured credentials. Network connectivity to AWS endpoints is mandatory. Some operations, like receiving messages, might return empty responses if no messages are available, or might be affected by visibility timeouts for messages already being processed.

<B>CONFIGURATION</B>

Before using "aws sqs" commands, ensure your AWS CLI is configured using aws configure. This sets up your AWS Access Key ID, Secret Access Key, default region, and preferred output format (e.g., json, text, table).

<B>OUTPUT FORMATS</B>

The AWS CLI supports various output formats. You can specify the output format for a command using the --output global option, for example, --output json for programmatic parsing, --output text for simple text output, or --output table for human-readable tabular data.

<B>GLOBAL OPTIONS</B>

Beyond API-specific parameters, "aws sqs" commands can use global AWS CLI options such as --region (to override the default region), --profile (to use a specific named profile from your credentials file), and --debug (for detailed logging).

HISTORY

Amazon SQS is one of the oldest and most fundamental AWS services, launched in 2004. The AWS Command Line Interface (CLI) itself was first released in 2013, providing a unified and consistent interface for interacting with all AWS services, including SQS. The integration of SQS functionalities into the AWS CLI has steadily evolved, reflecting new SQS features and improvements, providing developers and operations teams with robust command-line capabilities for automation, scripting, and direct management of message queues.

SEE ALSO

aws(1), aws s3(1), aws ec2(1)

Copied to clipboard