Shorthand 用于 sqs 的 aws-cli 中发送消息命令中消息属性的语法
Shorthand syntax for message-attributes in the send-message command in aws-cli for sqs
尝试使用适用于 SQS 的 AWS CLI 发送消息时,我无法使用 --message-attributes
参数的 shorthand 语法。
指定 json 文件工作正常,参考没有显示 shorthand 选项的示例。
这是此命令的参考,它指定了 shorthand 我正在尝试使用但无法使其工作:http://docs.aws.amazon.com/cli/latest/reference/sqs/send-message.html
这是我试过的命令:
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"}
我不断收到错误消息:
Parameter validation failed: Invalid type for parameter
MessageAttributes.contentType, value: StringValue=Snapshot, type:
, valid types:
有人曾经使用 shorthand 管理过消息的发送属性吗?
目前,--message-attributes
选项的简写语法文档不正确,简写语法不起作用。
相反,您可以使用 JSON 文件(如您所述)。您还可以使用内联 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"} }'
您的 Shorthand 语法格式正确:
MY_KEY={DataType=String, StringValue=MY_VALUE}
您只是忘记用单引号或双引号将命令行选项括起来:
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"}'
上面的快捷语法应该正确地生成一条消息,其中包含 2 个额外的 headers、a.k.a。消息属性:
firstAttribute=hello world
secondAttribute=goodbye world
注意:
一个属性是一个 <class 'dict'>
,所以每个属性看起来都像一个字典:{DataType=String, StringValue=MY_VALUE}
,
其中支持的 DataType
是 String、Number 和
二进制.
每个 DataType 值都可以包含一个可选的自定义扩展名,aws 会忽略它。例如:String.uuid、Number.int、
Binary.pdf.
尝试使用适用于 SQS 的 AWS CLI 发送消息时,我无法使用 --message-attributes
参数的 shorthand 语法。
指定 json 文件工作正常,参考没有显示 shorthand 选项的示例。
这是此命令的参考,它指定了 shorthand 我正在尝试使用但无法使其工作:http://docs.aws.amazon.com/cli/latest/reference/sqs/send-message.html
这是我试过的命令:
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"}
我不断收到错误消息:
Parameter validation failed: Invalid type for parameter MessageAttributes.contentType, value: StringValue=Snapshot, type: , valid types:
有人曾经使用 shorthand 管理过消息的发送属性吗?
目前,--message-attributes
选项的简写语法文档不正确,简写语法不起作用。
相反,您可以使用 JSON 文件(如您所述)。您还可以使用内联 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"} }'
您的 Shorthand 语法格式正确:
MY_KEY={DataType=String, StringValue=MY_VALUE}
您只是忘记用单引号或双引号将命令行选项括起来:
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"}'
上面的快捷语法应该正确地生成一条消息,其中包含 2 个额外的 headers、a.k.a。消息属性:
firstAttribute=hello world
secondAttribute=goodbye world
注意:
一个属性是一个 <class 'dict'>
,所以每个属性看起来都像一个字典:{DataType=String, StringValue=MY_VALUE}
,
其中支持的
DataType
是 String、Number 和 二进制.每个 DataType 值都可以包含一个可选的自定义扩展名,aws 会忽略它。例如:String.uuid、Number.int、 Binary.pdf.