Skip to content

Instantly share code, notes, and snippets.

import json
import boto3
def lambda_handler(event, context):
region_name = os.environ['AWS_REGION']
if event:
for record in event['Records']:
body = record['body']
# process message
return {
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(
import os
import json
import boto3
def lambda_handler(event, context):
region_name = os.environ['AWS_REGION']
if event:
sqs = boto3.resource('sqs', region_name=region_name)
queue_name = event['Records'][0]['eventSourceARN'].split(':')[-1]
queue = sqs.get_queue_by_name(QueueName=queue_name)
import os
import json
import boto3
def lambda_handler(event, context):
if event:
messages_to_reprocess = []
batch_failure_response = {}
for record in event["Records"]:
try:
@zdotfive
zdotfive / cognito-test.py
Created January 29, 2022 07:42 — forked from bgdnlp/cognito-test.py
Sign up and log in to Cognito, check tokens, then call an API. Details: https://www.neant.ro/aws/working-with-cognito-and-api-gateway-in-python.html
#!/usr/bin/env python3
# Demonstrates the use of Python to work with Cognito.
# Create a new a user, log in, check tokens and call an API.
# The purpose was to learn about Cognito. Security has been
# circumvented in the interest of keeping it simple.
# Notably, the authentication procedure uses the most insecure
# method. This code is not intended for use in production.
#
# https://www.neant.ro/aws/working-with-cognito-and-api-gateway-in-python.html
# needs Python3, though easily adapted
from __future__ import unicode_literals
import boto3
def main():
session = boto3.session.Session(profile_name='aws_credentials_profile')
ec2 = session.resource('ec2')
# define instance parameters
[
{
"id": 1,
"thumbnail": "aquaman",
"title": "Ciccio Pasticcio",
"description": "Once home to the most advanced civilization on Earth, the city of Atlantis is now an underwater kingdom ruled by the power-hungry King Orm. With a vast army at his disposal, Orm plans to conquer the remaining oceanic people -- and then the surface world. Standing in his way is Aquaman, Orm's half-human, half-Atlantean brother and true heir to the throne. With help from royal counselor Vulko, Aquaman must retrieve the legendary Trident of Atlan and embrace his destiny as protector of the deep.",
"trailerLink" : "https://www.youtube.com/watch?v=WDkg3h8PCVU",
"catagory": "DC",
"isFeaturedMovie": false