I am trying to subscribe to an SNS topic with a lambda function as endpoint.
On trying via AWS console, it works perfectly fine. A subscription is added in SNS->Subscriptions which in turn also adds a trigger to lambda function in Lambda->Functions->[function_name]->Triggers
On trying the same thing via boto3 or AWS cli, it adds new subscription, but no trigger gets added in Lambda->Functions->[function_name]->Triggers. As a result lambda function doesn't get triggered for this SNS topic.
import boto3
client = boto3.client('sns')
sns_topic_arn = '<sns_topic_arn>'
lambda_fn_arn = '<lambda_fn_arn>'
response = client.subscribe(TopicArn=sns_topic_arn,Protocol='lambda',
Endpoint=lambda_fn_arn)
I made sure that sns_topic_arn and lambda_fn_arn are correct. Am I missing something?