AWS SNS CLI Command Publish Message Attributes

If you want to send a message attributes using AWS SNS using CLI you can make use of the aws sns publish command and --message-attributes option.

Syntax:
aws sns publish --topic-arn arn 

--message "Testing AWS SNS with message attributes" 
--message-attributes attribute_name={DataType=String,StringValue=value} 
          attribute_name={DataType=Number,StringValue=value}

DataType: The data type of the attribute can be a String, Number, or Binary.

Example:

aws sns publish 
--topic-arn arn:aws:sns:us-east-1:13xx6xx9xx:smsTopic 
--message "Important notification" 
--message-attributes 
  Name={DataType=String,StringValue=Sam} Age={DataType=Number,StringValue=22}
AWS SNS CLI Topic Message Attributes Example

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!