Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon Can I use a JSON file to set ReceiveMessageWaitTimeSeconds for multiple queues in AWS CLI


Can I use a JSON file to set ReceiveMessageWaitTimeSeconds for multiple queues in AWS CLI


Yes, you can use a JSON file to set the `ReceiveMessageWaitTimeSeconds` attribute for multiple queues in AWS CLI. Here is an example:

1. Create a JSON File:
Create a JSON file named `set-queue-attributes.json` with the following content:

json
   {
     "ReceiveMessageWaitTimeSeconds": 5
   }
   

2. Set Queue Attributes:
Use the `aws sqs set-queue-attributes` command with the JSON file:

bash
   aws sqs set-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue --attributes file://set-queue-attributes.json
   

This command sets the `ReceiveMessageWaitTimeSeconds` attribute to 5 seconds for the specified queue. You can repeat this process for multiple queues by updating the `queue-url` and the JSON file accordingly[3][4].

Here is a more detailed example of setting attributes for multiple queues from a JSON file:

bash
# Create a JSON file
$ echo '{"ReceiveMessageWaitTimeSeconds": 5}' > set-queue-attributes.json

# Set attributes for multiple queues
$ aws sqs set-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue1 --attributes file://set-queue-attributes.json
$ aws sqs set-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue2 --attributes file://set-queue-attributes.json

In this example, the `set-queue-attributes.json` file contains the attribute `ReceiveMessageWaitTimeSeconds` set to 5 seconds. This attribute is applied to both `MyQueue1` and `MyQueue2` using the `aws sqs set-queue-attributes` command[3][4].

Citations:
[1] https://docs.aws.amazon.com/cli/v1/userguide/cli_sqs_code_examples.html
[2] https://docs.aws.amazon.com/cli/latest/reference/sqs/receive-message.html
[3] https://plainenglish.io/blog/aws-sqs-cli-commands-with-examples-abb9a0f0e362
[4] https://docs.aws.amazon.com/cli/latest/reference/sqs/get-queue-attributes.html
[5] https://github.com/aws/aws-cli/issues/96