I try to send a message to an SNS topic after the lambda function is done.
For that I return from the lambda handler function the message (python).
Lambda executes without error and returns the message correctly. IAM is set to allow the lambda to publish to the specific SNS topic.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "None",
"Effect": "Allow",
"Action": [
"sns:Publish",
"sns:Subscribe",
"sns:ConfirmSubscription"
],
"Resource": "arn:aws:sns:eu-central-1:123456789012:TOPIC"
}
]
}
simplified code of lambda is:
#import packages
def handler(event, context) -> dict:
"""
lambda handler function for invoking session
param event: json/dict like key:val mapping for regular lambda invocations with custom topics (e.g. different data pipeline stage, different customers etc.)
param context: AWS logging
return: dict like key:val mapping to deliver custom topics to AWS Service invocations
"""
#-----# key:val mapping #-----#
'''
'''
Message = event["Records"][0]["Sns"]["Message"]
Message = Message.replace("'", "\"")
Message = json.loads(Message)
#does lot's of stuff here
#eg. getting data from S3, posting data to S3
#send topic to SNS is NOT used, since it should be configured by the general lambda settings as endpoint destination.
# -----# update key:val mapping #-----#
event = {
"timestamp": timestamp
}
return event
is there anything else one has to do? Because after inspecting cloudwatch logs, no messages arrive at the SNS.