AWS SNS Invalid parameter TopicArn Error

Read this post if you want to solve the AWS SNS Invalid parameter TopicArn error. First off! This AWS SNS Topic ARN message is quite misleading. Read below to see why.

You should see an error similar to this one:

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

How to find the error

This error will display one of the following messages:

  • The “An error occurred (InvalidParameter) when calling the Publish operation: Invalid parameter: TopicArn” error will display in the Linux console when you run the AWS CLI SNS Publish command via Bash.
  • The “botocore.exceptions.ClientError: An error occurred (InvalidParameter) when calling the Publish operation: Invalid parameter: TopicArn” error will display as an exception when you run the AWS CLI SNS Publish command via BotoCore.
  • Similar error messages exist for other platforms.

What are the possible cause(s)

The following cause(s) have been identified:

  • You are using an incorrect topic for the region. For example, you are using us-west-2, but default your SNS client is pointing to us-east-1.

Analysing the cause(s)

Check your AWS default region that is configured in your code or via AWS Configure.

Example of “AWS Configure” response in Linux:

ubuntu@server:/home/ubuntu$ aws configure
AWS Access Key ID [****************WJNA]:
AWS Secret Access Key [****************MbrW]:
Default region name [us-east-1]:
Default output format [json]:

Example Bash code that calls the AWS CLI SNS Publish Command:

/usr/bin/aws sns publish --topic-arn arn:aws:sns:ap-southeast-2:111111111111:ap-dev-status --message "Hello world!"

Note that the AWS configure command mentions the default region as “us-east-1”.

The TopicARN is located in “ap-southeast-2”. You will thus see the “Invalid parameter: TopicArn” error when you publish an SNS message to anywhere other than “ap-southeast-2”.

The reason for this is because the Topic ARN does not exist in ” us-east-1″.

Solution(s) for this issue

Solve this error using one of the following solution(s):

You can either change the default region by using AWS Configure.

See an example below when using Linux Bash:

ubuntu@server:/home/ubuntu$ aws configure
AWS Access Key ID [****************WJNA]:
AWS Secret Access Key [****************MbrW]:
Default region name [ap-southeast-2]:
Default output format [json]:

Or you can be explicit and specify the region in the AWS SNS Publish call:

An example of the Bash AWS CLI SNS Publish Call via PHP:

$SnSclient = new SnsClient([
    'profile' => 'default',
    'region' => 'us-east-1',
    'version' => '2010-03-31'
]);

An example of the Bash AWS CLI SNS Publish Call via Bash:

/usr/bin/aws sns publish --region ap-southeast-2 --topic-arn arn:aws:sns:ap-southeast-2:111111111111:ap-dev-status --message "$MSG"

Add the “– region” parameter and specify the region of the Topic ARN.

Wrapping up

How did you solve this issue? Let Anto Online know in the comments below.

You may also be interested in



About the Authors

Anto's editorial team loves the cloud as much as you! Each member of Anto's editorial team is a Cloud expert in their own right. Anto Online takes great pride in helping fellow Cloud enthusiasts. Let us know if you have an excellent idea for the next topic! Contact Anto Online if you want to contribute.

Support the Cause

Support Anto Online and buy us a coffee. Anything is possible with coffee and code.

Buy me a coffee



About Anto Online

Having started his career in 1999 as a Desktop Support Engineer, Anto soon changed paths and became a developer. After several years of development experience, he transitioned into a consultant. As an enterprise application consultant for a leading SaaS software provider, Anto specializes in AWS's serverless technologies. By day, Anto focuses on helping customers leverage the power of serverless technologies. By night, he indulges his passion for cloud computing by playing with Python and trying out things that are currently beyond the scope of his work. Sometimes Anto needs help as there are not enough hours at night. So Anto relies on a team of fellow Cloud enthusiasts to help him out. Each one is a Cloud expert in their own right, and Anto takes great pride in helping them learn and grow.

View all posts by Anto Online →

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.