Reputation:
I have an AWS Lambda that is triggered through API Gateway set up with the following code:
import json
import boto3
def lambda_handler(event, context):
client = boto3.client('sns')
response = client.publish(
TargetArn='arn:aws:sns:us-east-1:264604750251:Billing_SubscriptionMessage_1',
Message=json.dumps({'default': json.dumps(event['body'])}),
MessageStructure='json'
)
return response
However, it seems that event
does not have the body
key.
I'm using this Lambda with AWS Gateway in order to serve as a webhook listener. I want to pass the webhook data to my SNS topic.
Upvotes: 1
Views: 1729
Reputation:
Turns out I was using an AWS Gateway of type HTTP, while I needed one of type REST, which passes the request body by default.
Upvotes: 2