Skip to content

Instantly share code, notes, and snippets.

import boto3
def main():
# 1 - Create Client
ddb = boto3.resource('dynamodb',
endpoint_url='http://localhost:8000',
region_name='dummy',
aws_access_key_id='dummy',
aws_secret_access_key='dummy')
# 2 - Create the Table
ddb.create_table(TableName='Transactions',
import boto3
def lambda_handler(event, context):
client = boto3.resource('dynamodb')
table = client.Table('YOUR TABLE NAME')
# S, N, M, L, B, SS, NS
input = {'TransactionId': '31', 'State': 'PENDING',
'RelatedTransactions': [32, 33, 34],
'CustomerDetails': { 'Name': 'John Doe', 'AccountBalance': 50}}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"dynamodb:PutItem"
],
"Resource": "*"
import json
import boto3
client = boto3.client('lambda')
def lambda_handler(event, context):
inputForInvoker = {'CustomerId': '123', 'Amount': 50 }
response = client.invoke(
FunctionName='YOUR LAMBDA ARN',
@djg07
djg07 / policy
Created December 29, 2019 21:41
AWSLambdaBasicExecutionPolicy
---
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
import json
import boto3
import uuid
client = boto3.client('stepfunctions')
def lambda_handler(event, context):
#INPUT -> { "TransactionId": "foo", "Type": "PURCHASE"}
transactionId = str(uuid.uuid1()) #90a0fce-sfhj45-fdsfsjh4-f23f
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
S3 PutObject Role
---
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "s3:PutObject",
"Resource": "*"
@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'
@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",