Chamin Wickramarathna
Chamin Wickramarathna

Reputation: 1832

AWS SNS error - Invalid parameter while publishing message using aws-cli

I am working with AWS SNS services and completed the initial setup as the AWS documentation. I just needed to test it using aws-cli. So I used the following command to publish a test message to SNS topic from my local PC.

aws sns publish --topic-arn "arn:aws:sns:us-east-1:xxxxxxxxxxx:test-notification-service" --message "Hello, from SNS"

However, I got stuck on the following generic error. It just says Invalid Parameter. I have configured the ~/.aws/credentials as needed.

An error occurred (InvalidParameter) when calling the Publish operation: Invalid parameter: TopicArn

Upvotes: 15

Views: 44828

Answers (2)

hit3k
hit3k

Reputation: 1493

You can just add region parameter --region us-east-1 to your command:

aws sns publish --topic-arn "arn:aws:sns:us-east-1:xxxxxxxxxxx:test-notification-service" --message "Hello, from SNS" --region us-east-1

Upvotes: 10

Aatish Sai
Aatish Sai

Reputation: 1687

The issue is due to cross-region. You AWS-CLI default region might be different to the region your SNS service location.

Check your AWS-CLI location and make sure you are in the same region as your SNS.

To check your region in AWS CLI use:

aws configure get region

To configure your AWS region you can use the command:

aws configure set region <region-name>

https://docs.aws.amazon.com/cli/latest/reference/configure/set.html

Upvotes: 27

Related Questions