Carlos Aguni

Highly motivated self-taught IT analyst. Always learning and ready to explore new skills. An eternal apprentice.


Lambda SQS Cheat Sheet

21 May 2020 » aws
import json
import boto3

def lambda_handler(event, context):
    sqs = boto3.resource('sqs')
    queue =sqs.get_queue_by_name(QueueName='sqs-test-backup')
    resp = queue.send_message(MessageBody='message from lambda', 
                              MessageAttributes={
                                  'foo': {
                                      'StringValue': 'bar',
                                      'DataType': 'String'
                                  }
                              })
    print('MessageId', resp.get('MessageId')) 
    print('MD5OfMessageBody', resp.get('MD5OfMessageBody'))
    return 'ok'