Skip to content

Instantly share code, notes, and snippets.

import json
import urllib.parse
import boto3
print('Loading function')
s3 = boto3.client('s3')
def lambda_handler(event, context):
#1 - Get the bucket name
@djg07
djg07 / lambda_handler.py
Created August 18, 2019 17:45
DynamoDB Streams Lambda Handler
import json
print('Loading function')
def lambda_handler(event, context):
print('------------------------')
print(event)
#1. Iterate over each record
try:
for record in event['Records']:
import json
print('Loading function')
def lambda_handler(event, context):
#1. Parse out query string params
transactionId = event['queryStringParameters']['transactionId']
transactionType = event['queryStringParameters']['type']
transactionAmount = event['queryStringParameters']['amount']
@djg07
djg07 / ASL
Created September 14, 2019 01:46
{
"Comment": "A simple AWS Step Functions state machine that automates a call center support session.",
"StartAt": "ProcessTransaction",
"States": {
"ProcessTransaction": {
"Type" : "Choice",
"Choices": [
{
"Variable": "$.TransactionType",
"StringEquals": "PURCHASE",
from __future__ import print_function
import json
import urllib
import boto3
import datetime
print('Loading message function...')
def process_refund(message, context):
{
"Comment":"Transaction Processor State Machine Using SQS",
"StartAt":"ProcessTransaction",
"States":{
"ProcessTransaction":{
"Type":"Pass",
"Next":"BroadcastToSqs"
},
"BroadcastToSqs":{
"Type":"Task",
@djg07
djg07 / SNS
Created October 30, 2019 00:39
{
"Comment":"Transaction Processor State Machine Using SNS",
"StartAt":"ProcessTransaction",
"States":{
"ProcessTransaction":{
"Type":"Pass",
"Next":"BroadcastToSns"
},
"BroadcastToSns":{
"Type":"Task",
@djg07
djg07 / handler.py
Created November 6, 2019 02:12
Handler
#Talk python to me
import json
import boto3
s3 = boto3.client('s3')
def lambda_handler(event, context):
bucket = 'aws-simplified-transactions'
key = 'transactions.json'
S3 PutObject Role
---
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "s3:PutObject",
"Resource": "*"
import json
import boto3
from boto3.dynamodb.conditions import Key
def lambda_handler(event, context):
client = boto3.resource('dynamodb')
table = client.Table('Transactions')
#1. Example - Get Item By Id