Created
April 19, 2023 00:41
-
-
Save AngelChaidez/f7f215ce7168fe5c7e1e792fcd513421 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
#!/usr/bin/ env python3.11 | |
# This script will send messages to an SQS queue | |
import boto3 | |
import json | |
import random | |
from datetime import datetime | |
from botocore.exceptions import ClientError | |
import string | |
# Function will send in messages to our SQS queue, the messages will compose of todays date followed by | |
# 5 random alphanumeric characters. We will send our messages to our QueueUrl | |
def lambda_handler(event, context): | |
todays_date = datetime.now().strftime("%Y-%m-%d") | |
message = todays_date +"".join(random.choices(string.ascii_letters + string.digits, k=5)) | |
sqs = boto3.client('sqs') | |
print(message) | |
sqs = boto3.client('sqs') | |
response = sqs.send_message( | |
QueueUrl='https://sqs.us-east-1.amazonaws.com/758719472525/SQS_2023-04-17', | |
MessageBody= (f"Sucessfully sent: {message}") | |
) | |
return { | |
'statusCode': 200, | |
'body': json.dumps(response, indent=4) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment