Adding SQS redrive policy using AWS CLI command Adding SQS redrive policy using AWS CLI command unix unix

Adding SQS redrive policy using AWS CLI command


Have you tried just creating the JSON in a separate file and passing it as an argument to your AWS CLI command? I find it's difficult to get all of the escaping correct when passing the JSON as a parameter. So you'd basically do it as the example shows in the AWS documentation:

https://docs.aws.amazon.com/cli/latest/reference/sqs/set-queue-attributes.html#examples

  1. So first you'd create a new file called "set-queue-attributes.json" like so:
    {      "DelaySeconds": "10",      "MaximumMessageSize": "131072",      "MessageRetentionPeriod": "259200",      "ReceiveMessageWaitTimeSeconds": "20",      "RedrivePolicy": "{\"deadLetterTargetArn\":\"arn:aws:sqs:us-east-1:80398EXAMPLE:MyDeadLetterQueue\",\"maxReceiveCount\":\"1000\"}",      "VisibilityTimeout": "60"    }
  1. Then run the command like this:
aws sqs set-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyNewQueue --attributes file://set-queue-attributes.json --region=us-east-1