When trying to send a message using AWS CLI for SQS, I cannot get the shorthand syntax for the --message-attributes
parameter to work.
Specifying a json file works fine, and the reference doesn't show an example for the shorthand option.
Here is the reference for this command which specifies the shorthand I'm trying to use but I can't get it to work: http://docs.aws.amazon.com/cli/latest/reference/sqs/send-message.html
Here's the command I've tried:
aws sqs send-message \
--queue-url https://sqs.us-east-1.amazonaws.com/0000000000/aa_queue_name \
--message-body "message body goes here" \
--message-attributes firstAttribute={DataType=String,StringValue="hello world"},secondAttribute={DataType=String,StringValue="goodbye world"}
I keep getting error messages:
Parameter validation failed: Invalid type for parameter MessageAttributes.contentType, value: StringValue=Snapshot, type: , valid types:
Anyone ever managed sending attributes for message using the shorthand?
Currently, the documentation of the short-hand syntax for the --message-attributes
option is incorrect and the short-hand syntax does not work.
Instead, you can use the JSON file (as you mentioned). You can also use the inline JSON:
aws sqs send-message
--queue-url https://sqs.us-east-1.amazonaws.com/0000000000/aa_queue_name
--message-body "message body goes here"
--message-attributes '{ "firstAttribute":{ "DataType":"String","StringValue":"hello world" }, "secondAttribute":{ "DataType":"String","StringValue":"goodbye world"} }'
MY_KEY ={DataType= String , StringValue= MY_VALUE }
You just forgot to enclose the commandline option with single or double quotes:
aws sqs send-message \
--queue-url https://sqs.us-east-1.amazonaws.com/0000000000/aa_queue_name \
--message-body "message body goes here" \
--message-attributes 'firstAttribute={DataType=String, StringValue="hello world"}, secondAttribute={DataType=String,StringValue="goodbye world"}'
The above shortcut syntax should correctly produce a message with 2 extra headers, aka Message Attributes:
firstAttribute=hello world
secondAttribute=goodbye world
an attribute is a <class 'dict'>
, so every attribute looks like a dictionary: {DataType=String, StringValue=MY_VALUE}
,
where supported DataType
s are String , Number , or Binary .
each DataType value can contain an optional custom extention, that is ignored by AWS. For example: String.uuid , Number.int , Binary.pdf .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.