This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "VisualEditor0", | |
"Effect": "Allow", | |
"Action": [ | |
"dynamodb:PutItem" | |
], | |
"Resource": "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSLambdaBasicExecutionPolicy | |
--- | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"logs:CreateLogGroup", | |
"logs:CreateLogStream", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
S3 PutObject Role | |
--- | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "VisualEditor0", | |
"Effect": "Allow", | |
"Action": "s3:PutObject", | |
"Resource": "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Talk python to me | |
import json | |
import boto3 | |
s3 = boto3.client('s3') | |
def lambda_handler(event, context): | |
bucket = 'aws-simplified-transactions' | |
key = 'transactions.json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Comment":"Transaction Processor State Machine Using SNS", | |
"StartAt":"ProcessTransaction", | |
"States":{ | |
"ProcessTransaction":{ | |
"Type":"Pass", | |
"Next":"BroadcastToSns" | |
}, | |
"BroadcastToSns":{ | |
"Type":"Task", |
NewerOlder