Skip to content

Instantly share code, notes, and snippets.

View adhorn's full-sized avatar

Adrian Hornsby adhorn

View GitHub Profile
aws comprehend detect-sentiment --text "What is the difference between a Zippo and a hippo?  ✔  10:44:06
Ones really heavy, and the other is a little lighter" --language-code "en"
{
"SentimentScore": {
"Mixed": 0.047000035643577576,
"Positive": 0.22732417285442352,
"Neutral": 0.5861609578132629,
"Negative": 0.13951489329338074
},
"Sentiment": "NEUTRAL"
stream: arn:aws:dynamodb:us-east-1:xxxxxxxxxxx:table/global2/stream/2018-05-14T21:09:15.761
http POST https://global.adhorn.me/create "session_comment"="It is a love hate relationship" "item_id"="newfoobar"  ✔  10:44:23
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 23
Content-Type: application/json
Date: Thu, 24 May 2018 08:01:34 GMT
X-Amzn-Trace-Id: Root=1-5b06715d-93f96b7aed2c93935e2f0437
x-amz-apigw-id: HYamrEtMPHcFSUQ=
x-amzn-RequestId: ace920db-5f28-11e8-9a4f-8341de6cad86
@adhorn
adhorn / gist:a2ad8cdba586e1c1e231bd007f0f064b
Created May 24, 2018 10:40
DynamoDB stream object - type INSERT
{
u'Records':[
{
u'eventID':u'09a77cc835e8baeeeec400efc3d69295',
u'eventVersion':u'1.1',
u'dynamodb':{
u'SequenceNumber':u'45152900000000035196046782',
u'Keys':{
u'item_id':{
u'S':u'foobar11'
http POST https://global.adhorn.me/create "session_comment"="It is a love hate relationship" "item_id"="foobar11"  ✔  13:34:25
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 24
Content-Type: application/json
Date: Thu, 24 May 2018 10:46:14 GMT
X-Amzn-Trace-Id: Root=1-5b0697f6-8fb9c837297aa8e2e7e2ab7b
x-amz-apigw-id: HYyufGVvPHcF-OA=
x-amzn-RequestId: ae185ab8-5f3f-11e8-9bc3-61481c62f7b2
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 / gist:cd15c271a05204712179cd27d6e07881
Created May 24, 2018 13:14
Filter ARN from DynamoDB table CLI query
aws dynamodb describe-table --table-name global2 --region us-east-1 --query "Table.LatestStreamArn"
"arn:aws:dynamodb:us-east-1:xxxxxxxxxxxx:table/global2/stream/2018-05-14T21:09:15.761"
@adhorn
adhorn / gist:8b0903c9807446ea90257b28ff191c19
Last active June 28, 2018 07:40
SQS Lambda Permission
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sqs:ListQueues",
"Resource": "*"
},
{
"Effect": "Allow",
@adhorn
adhorn / lambda.py
Created June 28, 2018 07:42
Lambda Function to check SQS Trigger
import json
def lambda_handler(event, context):
body = {
"message": "Hello SQS",
"event": event
}
print json.dumps(body)
START
Create a Base AMI and harden it if you have too.
IF DOCKER:
Create base Container with libraries and dependencies and store it in your container hub (you don't want to recreate the whole container every time)
Create an as-light-as possible Dockerfile (used a base container)
Copy code on build into Docker Container (run dockerfile)
Deploy Container to base AMI