Hey, this was very helpful. I was wondering if you could help me in identifying resources on how to send SQS msgs from code to SQS queue with all the dynamic parameters and not hardcoded.
Yes, below is the code to use aws lambda to send messages to the sqs queue. import os import boto3 def send_message_to_sqs(queue_url, message_body): sqs = boto3.client('sqs') response = sqs.send_message( QueueUrl=queue_url, MessageBody=message_body ) return response def lambda_handler(event, context): try: queue_url = os.environ.get('SQS_QUEUE_URL') message_body = "Hello, SQS!" if queue_url: response = send_message_to_sqs(queue_url, message_body) return { 'statusCode': 200, 'body': f"Message sent successfully. Message ID: {response['MessageId']}" } else: return { 'statusCode': 500, 'body': "SQS_QUEUE_URL environment variable is not set." } except Exception as e: return { 'statusCode': 500, 'body': f"An error occurred: {str(e)}" } Instructions: Here's how you can set it up: Create a new AWS Lambda function using the AWS Management Console. Configure the function to use the appropriate runtime (Python). Set the necessary environment variables (SQS_QUEUE_URL) in the Lambda function's configuration. Paste the modified code into the Lambda function's code editor. Save and deploy the Lambda function. When the Lambda function is triggered, it will attempt to send a message to the specified SQS queue using the provided environment variables. Please note that you need to ensure that the IAM role associated with the Lambda function has the necessary permissions to send messages to the SQS queue and access any other AWS resources required by your use case.
Hi Gaurav, As you mentioned, In Amazon SNS (Simple Notification Service/SES), the confirmation process for email subscriptions typically occurs only in sandbox and not in production environments. So if i deploy my code in producation environement there is no need of email subscription, as we can directly send an email to particular email?. 2. How can i bypass email subscription process while i am implementing in my local?
Exactly what I needed Gaurav! Thanks so much for walking through this and providing sample code!!
Why not set it up to parse the to and from addresses from the MIME content itself?
Great video.
Glad you enjoyed it
Nice explanation
thanks
Hey, this was very helpful. I was wondering if you could help me in identifying resources on how to send SQS msgs from code to SQS queue with all the dynamic parameters and not hardcoded.
Yes, below is the code to use aws lambda to send messages to the sqs queue.
import os
import boto3
def send_message_to_sqs(queue_url, message_body):
sqs = boto3.client('sqs')
response = sqs.send_message(
QueueUrl=queue_url,
MessageBody=message_body
)
return response
def lambda_handler(event, context):
try:
queue_url = os.environ.get('SQS_QUEUE_URL')
message_body = "Hello, SQS!"
if queue_url:
response = send_message_to_sqs(queue_url, message_body)
return {
'statusCode': 200,
'body': f"Message sent successfully. Message ID: {response['MessageId']}"
}
else:
return {
'statusCode': 500,
'body': "SQS_QUEUE_URL environment variable is not set."
}
except Exception as e:
return {
'statusCode': 500,
'body': f"An error occurred: {str(e)}"
}
Instructions:
Here's how you can set it up:
Create a new AWS Lambda function using the AWS Management Console.
Configure the function to use the appropriate runtime (Python).
Set the necessary environment variables (SQS_QUEUE_URL) in the Lambda function's configuration.
Paste the modified code into the Lambda function's code editor.
Save and deploy the Lambda function.
When the Lambda function is triggered, it will attempt to send a message to the specified SQS queue using the provided environment variables.
Please note that you need to ensure that the IAM role associated with the Lambda function has the necessary permissions to send messages to the SQS queue and access any other AWS resources required by your use case.
Thankyou so much. @@AWSTrainingByGauravAgrawal
this lambda code is not working.. Please help
What is the error that you are getting ??
Hi Gaurav, As you mentioned, In Amazon SNS (Simple Notification Service/SES), the confirmation process for email subscriptions typically occurs only in sandbox and not in production environments. So if i deploy my code in producation environement there is no need of email subscription, as we can directly send an email to particular email?.
2. How can i bypass email subscription process while i am implementing in my local?
You cannot bypass email subscription in local and for production setup, subscription is not required
@@AWSTrainingByGauravAgrawal Thank you Gaurav
@@AWSTrainingByGauravAgrawal Hi Gaurav.. Though I am using the aws dev account of my organisation, it is still asking for verification
I dont know why i am not getting emails
check spam folder
I didn't got the email
Didn’t u got an email while setting up the email in SES ? Check your spam
Folder also
No I don't got I hav also check spam 😕@@AWSTrainingByGauravAgrawal
Please go through the video again then, mostly all of the associates have received the email.
Yes vry helpful
@@AWSTrainingByGauravAgrawal do u have any vdo of how to create an S3 bucket??