import json
import boto3
def lambda_handler(event, context):
message = {'key': 'value'}
boto3.client('sns').publish(
TargetArn='YOUR ARN HERE',
Message=json.dumps({'default': json.dumps(message)}),
MessageStructure='json'
)
Inside a Python AWS Lambda function, you can import boto3
, which is the AWS SDK for Python.
You can then create a low-level client representing the SNS service with boto3.client('sns')
. With that client, you can call the publish()
method to publish a message to an SNS topic that has a given ARN.