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"}'
You can download this article in various formats for your convenience. Choose from the options below:
Facing issues? Have Questions? Post them here! I am happy to answer!
- Get the total size and number of objects of a AWS S3 bucket and folders
- How to Create AWS SNS Topic using AWS CLI
- Fix: Amazon Linux bash: sudo: command not found
- [Solution] AWS Java SDK S3 AmazonS3Exception InvalidAccessKeyId
- Create an AWS User using CLI2 Command at a specific Path
- Fix: Missing the following required SSO configuration values: sso_start_url, sso_region
- Fix: zsh: command not found: aws (Mac/macOS)
- Configure AWS Access ID and Secret Keys using CLI on Mac
- Quick way to setup AWS DynamoDB locally on macOS
- Most Essencial AWS CLI 2 S3 ls Command Options
- How to Check AWS SNS Permissions using CLI
- AWS CLI Change Default Output Format
- How to install AWS CLI on Ubuntu
- Quick way to install AWS CLI for macOS Terminal
- Install AWS CLI using Brew Command
- AWS CLI Command to Get a List of SNS Topics
- Get List of AWS SNS Topic Subscriptions using CLI
- How to Setup AWS Credentials using Visual Studio Code
- Installing AWS CLI Version 2 on macOS Sonoma using Terminal
- AW3 CLI command to get list of all region names
- AWS SNS CLI Command Publish Message Attributes
- Create an S3 bucket in a specific AWS region using CLI Command
- [Fix] zsh: command not found: awscli [Mac Terminal]
- Understanding AWS Calculator: DynamoDB on-demand capacity
- [Solution] com.amazonaws.dynamodb.v20120810 MissingAuthenticationToken Key Id or X.509 certificate
- Pure JavaScript Digital Clock Widget to get GMT/UTC Time Now - JavaScript
- [Java] NoClassDefFoundError Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory - Java
- Stop android adb service from command prompt or terminal - Android
- How to Split on String in Java with Regular Expressions by Dot. - Java
- Get the Complete Sha256 Container ID for Docker Run Command - Docker
- Nano Show Line Numbers - Linux
- Online Free Notepad App - Tools
- npm WARN saveError ENOENT: no such file or directory, open /mnt/c/package.json - JavaScript