If you want to publish a JSON Message to an AWS SNS Topic via the AWS CLI, you can make use of the aws sns publish command and pass the JSON string to the --message option.
Syntax:
aws sns publish --topic-arn topic-arn --message '{"json-key1": "json-value1", "json-key2": "json-value2"}'
Let's take a look at an example.
aws sns publish
--topic-arn arn:aws:sns:us-east-1:107xx89xx9xx:smsTopic
--message '{"type": "error", "message": "Error code 202 - Validation failed"}'

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!