Skip to content

Instantly share code, notes, and snippets.

View adhorn's full-sized avatar

Adrian Hornsby adhorn

View GitHub Profile
# Create DynamoDB endpoint in VPC
aws ec2 create-vpc-endpoint --vpc-id vpc-xxxxxx --service-name com.amazonaws.us-east-1.dynamodb --region us-east-1
{
"VpcEndpoint": {
"VpcEndpointId": "vpce-xxxxxx",
"VpcEndpointType": "Gateway",
"VpcId": "vpc-xxxxxxx",
"ServiceName": "com.amazonaws.us-east-1.dynamodb",
"State": "available",
# Finally adding the routing information for the endpoint
aws ec2 modify-vpc-endpoint --vpc-endpoint-id vpce-xxxxxx --add-route-table-ids rtb-xxxxxx --region us-east-1
{
"Return": true
}
@adhorn
adhorn / env_us-east-1.yml
Created May 3, 2018 12:08
Serverless framework to support deploy Lambda Functions in VPC
STATUS: 200
lambdaExecSecurityGroups: ["sg-xxxxxxx"]
subnets: ["subnet-xxxxxxx"]
@adhorn
adhorn / deploy
Created May 3, 2018 12:22
Deploying the backend
# Deploy in the us-east-1 region
serverless deploy --region us-east-1
# Deploy in the us-west-2 region
serverless deploy --region us-west-2
from __future__ import unicode_literals
import sys
import logging
import os
import json
import decimal
log = logging.getLogger()
log.setLevel(logging.DEBUG)
import json
import logging
import boto3
import os
import uuid
log = logging.getLogger()
log.setLevel(logging.DEBUG)
region = os.environ["AWS_REGION"]
@adhorn
adhorn / gist:d3c7a0ec1c072ed67911238254999c16
Created May 24, 2018 06:29
POST new item with comment
http POST https://global.adhorn.me/create "session_comment"="It is a love hate relationship" "item_id"="foobar"  ✔  13:50:02
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 23
Content-Type: application/json
Date: Fri, 18 May 2018 11:50:44 GMT
X-Amzn-Trace-Id: Root=1-5afebe14-da73f2310da0b2cd7b61f11f
x-amz-apigw-id: HFKjJE7-vHcFVgQ=
x-amzn-RequestId: b239568b-5a91-11e8-b612-b7f1413e87f0
@adhorn
adhorn / get.py
Created May 24, 2018 06:34
Get function to retrieve item from DynamoDB
from __future__ import unicode_literals
import sys
import logging
import boto3
import os
log = logging.getLogger()
log.setLevel(logging.DEBUG)
sys.path.insert(0, './vendored')
http https://global.adhorn.me/get/foobar  ✔  13:50:43
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 386
Content-Type: application/json
Date: Fri, 18 May 2018 11:50:48 GMT
X-Amzn-Trace-Id: Root=1-5afebe18-79fda21b908c34d743f9e5c1
x-amz-apigw-id: HFKj1FGMPHcFbIQ=
x-amzn-RequestId: b4d7cf60-5a91-11e8-a53f-c9e1bbeb06fe
@adhorn
adhorn / stream_handler.py
Created May 24, 2018 07:05
Function to react to DynamoDB stream
from __future__ import unicode_literals
import sys
import logging
import os
import json
import decimal
log = logging.getLogger()
log.setLevel(logging.DEBUG)