Petru
Petru

Reputation: 914

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?

Upvotes: 4

Views: 8854

Answers (1)

Jonathan Seed
Jonathan Seed

Reputation: 2017

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

Upvotes: 4

Related Questions