본 내용은 기업인턴과정에서 발생했던 내용을 정리한 내용입니다.
import json
import os
import boto3
import logging
from botocore.exceptions import ClientError
def lambda_handler(event, context):
e=event["name"]
_params = {'name': e}
msg_body = json.dumps(_params)
msg = send_sqs_message(os.environ['SQS_QUEUE'], msg_body)
return msg
def send_sqs_message(sqs_queue_url, msg_body):
sqs_client = boto3.client('sqs')
try:
msg = sqs_client.send_message(QueueUrl=sqs_queue_url,
MessageBody=msg_body)
except ClientError as e:
logging.error(e)
return None
return msg
참고 : https://sehajyang.github.io/2019/09/25/sqs-lambda-python/