Skip to content

Instantly share code, notes, and snippets.

IAM Policy
---
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"rds-db:connect"
],
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"cloudformation:DescribeStacks",
"cloudformation:CreateChangeSet",
"cloudformation:DescribeChangeSet",
CODE
---
import json
import uuid
GET_RAW_PATH = "/getPerson"
CREATE_RAW_PATH = "/createPerson"
def lambda_handler(event, context):
import json
import boto3
kinesis = boto3.client('kinesis')
def lambda_handler(event, context):
# PutRecord API Example
# ---------------------
import json
import boto3
client = boto3.client('rekognition')
# Permissions Required
# s3:GetObject
# rekognition:DetectFaces
# DetectFaces API Documentation - https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectFaces.html
AWS Kinesis PutRecord Documentation
----
https://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecord.html
Trust Policy for API Gateway
----
{
"Version": "2012-10-17",
"Statement": [
{
Config
---
{
"customerIds": ["1", "2", "3"]
}
Validator
---
{
"$schema": "http://json-schema.org/draft-04/schema#",
{
"Effect":"Allow",
"Principal":{
"AWS":"<SUBSCRIBER_ACCOUNT_ID>"
},
"Action":"sns:Subscribe",
"Resource":"arn:aws:sns:<REGION>:<PUBLISHER_ACCOUNT_ID>:<TOPIC_NAME>"
}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "*"
},
{
SELECT
Item.OrderId.S as OrderId,
Item.CustomerId.S as CustomerId,
Item.OrderDate.S as OrderDate,
Item.State.S as State,
Item.TotalAmount.N as TotalAmount,
Item.CancelledReasons.L as CancelledReasons,
Item.CancellationMetadata.M as CancellationMetadata
FROM data;