I am simply trying to publish to an SNS topic using a lambda function. The function code as follows, with ARN being the actual SNS topic ARN:
import boto3 print('Loading function') def lambda_handler(event, context): client = boto3.client('sns') response = client.publish( TargetArn='ARN', Message="Test", ) return response
The function execution role as access to SNS. In fact I even gave SNS full access. But I keep getting the error:
{ "errorMessage": "An error occurred (InternalFailure) when calling the Publish operation (reached max retries: 4): Unknown", "errorType": "ClientError", "stackTrace": [ " File "/var/task/lambda_function.py", line 6, in lambda_handlern response = client.publish(n", " File "/var/runtime/botocore/client.py", line 316, in _api_calln return self._make_api_call(operation_name, kwargs)n", " File "/var/runtime/botocore/client.py", line 626, in _make_api_calln raise error_class(parsed_response, operation_name)n" ] }
I do not find any access denied errors in cloudtrail either. Any idea on what is the issue here ?
Edit: Its my bad, I used the subscription ARN instead of the topic ARN causing this issue.
Advertisement
Answer
In case if anyone is facing this issue, make sure you use the correct ARN – use the ARN of the Topic instead of the subscription.