Map datatype in aws cli
I am trying to add a message to a queue in amazon aws sqs
so i tried this
root~# aws sqs send-message --queue-url "queue/url" --message-body "message with attribute" --message-attributes '{"Name": "somename", "Type":"String", "Value":"somevalue"}'
bit it gives me this error
'unicode' object has no attribute 'keys'
but if i remove the part --message-attributes
from the command
root~# aws sqs send-message --queue-url "queue/url" --message-body "message with attribute"
then it works fine
http://docs.aws.amazon.com/cli/latest/reference/sqs/send-message.html
I am guessing it is the card type, how to send this parameter in card format
--message-attributes (map)
+1
source to share
1 answer
You need to pass --message-attributes (map)
data structre as{attr1 : {"DataType":"type1.option", "StringValue":val1}, attr2 : {"DataType":"typ2.option", "StringValue":val2}, ...}
So your example looks like this:
send queue
$ aws sqs send-message --queue-url "queue/url" --message-body "message with attribute" --message-attributes '{"somename" : { "DataType":"String", "StringValue":"somevalue"}}'
{
"MD5OfMessageBody": "ZZZZ",
"MD5OfMessageAttributes": "YYYY",
"MessageId": "06524772-XXXX"
}
reception queue
$ aws sqs receive-message --queue-url "queue/url" --message-attribute-names somename
{
"Messages": [
{
"Body": "message with attribute",
"ReceiptHandle": "dummy==",
"MD5OfBody": "ZZZZ",
"MD5OfMessageAttributes": "YYYYS",
"MessageId": "06524772-XXXX",
"MessageAttributes": {
"somename": {
"DataType": "String",
"StringValue": "somevalue"
}
}
}
]
}
+5
source to share