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
-

Facing issues? Have Questions? Post them here! I am happy to answer!


Author Info:

Rakesh (He/Him) is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap