-
-
Save zdotfive/0eaa3969cced0019928fbe7c2a6e4990 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
import boto3 | |
def lambda_handler(event, context): | |
region_name = os.environ['AWS_REGION'] | |
if event: | |
sqs = boto3.client('sqs', region_name=region_name) | |
queue_name = event['Records'][0]['eventSourceARN'].split(':')[-1] | |
queue_url = sqs.get_queue_url( | |
QueueName=queue_name, | |
) | |
for record in event['Records']: | |
body = record['body'] | |
print(body) | |
# process message | |
response = sqs.delete_message( | |
QueueUrl=queue_url['QueueUrl'], | |
ReceiptHandle=record['receiptHandle'] | |
) | |
return { | |
'statusCode': 200, | |
'body': json.dumps('Message processed successfully!') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment