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"}'

-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to AWS,
- Create S3 bucket and upload files using AWS Toolkit for Visual Studio Code
- Get the total size and number of objects of a AWS S3 bucket and folders
- Create an S3 bucket in a specific AWS region using CLI Command
- [Solution] AWS Java SDK S3 AmazonS3Exception InvalidAccessKeyId
- Fix AWS CLI 2 SignatureDoesNotMatch Error - Signature we calculated does not match
- 573 List of reserved keywords in AWS DynamoDB
- Quick way to setup AWS DynamoDB locally on macOS
- [Solution] com.amazonaws.dynamodb.v20120810 MissingAuthenticationToken Key Id or X.509 certificate
- Quick way to install AWS CLI for macOS Terminal
- Setting and Updating AWS CLI Configuration
- AWS S3 CLI BucketAlreadyExists when calling CreateBucket Error make_bucket failed
- How to install AWS Toolkit for Visual Studio Code
- Create S3 bucket using AWS CLI Command mb
- Fix: zsh: command not found: aws (Mac/macOS)
- How to install AWS CLI on Ubuntu
- Fix: Amazon Linux bash: sudo: command not found
- How to Setup AWS Credentials using Visual Studio Code
- AW3 CLI command to get list of all region names
- Most Essencial AWS CLI 2 S3 ls Command Options
- Install AWS CLI using Brew Command
More Posts:
- How to add or remove bookmark on a line in Notepad++ - NotepadPlusPlus
- Stop android adb service from command prompt or terminal - Android
- Bash Command to Download a File From URL - Bash
- Convert JSON to Gson with type as ArrayList - Java
- Fix: error: unclosed character literal in Java - Java
- The package must have at least one . separator [Android Studio] - Android-Studio
- How to connect Relational and NoSQL databases with Spring Boot - HowTos
- How to Make Android TextView Text Bold - Android