Skip to content

Instantly share code, notes, and snippets.

View adhorn's full-sized avatar

Adrian Hornsby adhorn

View GitHub Profile
for i in {1..10}
do http POST https://globe.adhorn.me/create "item_id"="boo$i"
done
@adhorn
adhorn / env.yml
Last active April 25, 2018 03:11
STATUS: 200
@adhorn
adhorn / get.py
Last active April 25, 2018 03:12
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')
@adhorn
adhorn / Command Line to create the VPC
Last active May 3, 2018 09:11
Serverless template for global backend in VPC with DynamoDB endpoint
# create VPC in region us-east-1
aws ec2 create-vpc --cidr-block 10.0.0.0/16 --region us-east-1
{
"Vpc": {
"CidrBlock": "10.0.0.0/16",
"DhcpOptionsId": "dopt-f14eca94",
"State": "pending",
"VpcId": "vpc-xxxxxx",
"InstanceTenancy": "default",
"Ipv6CidrBlockAssociationSet": [],
# create VPC in region us-east-1
aws ec2 create-vpc --cidr-block 10.0.0.0/16 --region us-east-1
{
"Vpc": {
"CidrBlock": "10.0.0.0/16",
"DhcpOptionsId": "dopt-f14eca94",
"State": "pending",
"VpcId": "vpc-xxxxxx",
# Create subnet associated with the VPC
aws ec2 create-subnet --vpc-id vpc-xxxxxx --cidr-block 10.0.1.0/24 --region us-east-1
{
"Subnet": {
"AvailabilityZone": "us-east-1b",
"AvailableIpAddressCount": 251,
"CidrBlock": "10.0.1.0/24",
"DefaultForAz": false,
"MapPublicIpOnLaunch": false,
"State": "pending",
# Get the routing info from the VPC.
aws ec2 describe-route-tables --filters "Name=vpc-id,Values=vpc-xxxxxxx" --region us-east-1
{
"RouteTables": [
{
"Associations": [
{
"Main": true,
"RouteTableAssociationId": "rtbassoc-4112743e",
"RouteTableId": "rtb-xxxxxx"
#create the initial table with stream enabled in us-east-1
aws dynamodb create-table \
--table-name MyGlobalTable \
--attribute-definitions \
AttributeName=item_id,AttributeType=S \
--key-schema \
AttributeName=item_id,KeyType=HASH \
--provisioned-throughput \
ReadCapacityUnits=5,WriteCapacityUnits=5 \
--stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES \
# 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
}