Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS sqs send message batch from cli

I am trying to send a batch of messages from the command line using aws cli. The command looks like this:

aws sqs send-message-batch \
    --queue-url https://sqs.us-west-2.amazonaws.com/... \
    --region=us-west-2 \
    --cli-input-json "[{\"Id\":\"1\",\"MessageBody\":\"[344ED079FC85292446B193170E02F6C51882A761]\"},{\"Id\":\"2\",\"MessageBody\":\"[B584291B654587C7C957E10DF8B50FB31B2F589E]\"}]"

The problem is it returns an error code 255:

'list' object has no attribute 'keys'

Any idea what I am doing wrong?

like image 339
Petru Avatar asked Oct 14 '25 22:10

Petru


1 Answers

You are very close!
The cli help is kind of vague about this, but the argument for the --entries parameter can be provided with either JSON or shorthand syntax directly (without cli-input-json). So your command should look like:

aws sqs send-message-batch \
    --queue-url https://sqs.us-west-2.amazonaws.com/... \
    --region=us-west-2 \
    --entries "[{\"Id\":\"1\",\"MessageBody\":\"[344ED079FC85292446B193170E02F6C51882A761]\"},{\"Id\":\"2\",\"MessageBody\":\"[B584291B654587C7C957E10DF8B50FB31B2F589E]\"}]"

The --cli-input-json parameter is an optional parameter available on all cli commands that allows you to provide all arguments (not individual) for a command as json. It is unecessary in this case

like image 92
Jonathan Seed Avatar answered Oct 17 '25 12:10

Jonathan Seed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!