Skip to content

Instantly share code, notes, and snippets.

@keithrozario
keithrozario / serverless.yml
Created March 3, 2019 10:39
Serverless Yaml import region
provider:
name: aws
runtime: python3.7
stage: ${opt:stage, 'default'}
region: ${file(../infra/terraform.tfvars.json):aws_region.${self:provider.stage}}
@keithrozario
keithrozario / infra.tfvars.json
Created March 3, 2019 10:38
tfvars.json AWS Region
{
"app_name" : "cert-transparency",
"aws_region": {
"default" : "us-east-1",
"dev" : "ap-southeast-1"
}
}
@keithrozario
keithrozario / serverless.yml
Created March 3, 2019 10:02
serverless-example-import.yml
custom:
dbTempName: ${ssm:/${self:service.name}/${self:provider.stage}/dynamodb_temp_table}
dbTempArn: ${ssm:/${self:service.name}/${self:provider.stage}/dynamodb_temp_table_arn}
functions:
query_logs:
description: Query the certs from the Certificate Transparency Logs
handler: query_logs.query_to_db
environment:
db_table_name: ${self:custom.dbTempName}
@keithrozario
keithrozario / export-ssm.tf
Last active March 3, 2019 10:05
export-ssm
resource "aws_ssm_parameter" "ssm_dynamodb_temp_table" {
type = "String"
description = "Name of DynamoDB Temp Table"
name = "/${var.app_name}/${terraform.workspace}/dynamodb_temp_table"
value = "${aws_dynamodb_table.dynamodb_temp.name}"
overwrite = true
}
resource "aws_ssm_parameter" "ssm_dynamodb_temp_table_arn" {
type = "String"
@keithrozario
keithrozario / s3bucket_domains.tf
Created March 2, 2019 03:32
s3bucket_domains
resource "aws_s3_bucket" "s3bucket_domains" {
bucket = "${lookup(var.s3bucket_domains, terraform.workspace)}"
acl = "private"
force_destroy = false # prevent terraform from deleting this bucket if it has objects inside
}
@keithrozario
keithrozario / terraform-ex1.tfvars.json
Last active March 2, 2019 03:26
Example TFVARS file : 1
{
"app_name" : "cert-transparency",
"s3bucket_domains": {
"default" : "cert-domains",
"dev" : "cert-domains-dev"
},
"dynamodb_temp": {
"default": "cert-domains",
"dev": "cert-domains-dev"
}
@keithrozario
keithrozario / Contents.txt
Created February 17, 2019 11:09
Contents of /usr/bin in Lambda
a2p
addr2line
animate
appletviewer8
ar
as
aserver
awk
base64
bashbug
@keithrozario
keithrozario / delete_layers.py
Created January 5, 2019 12:57
Delete all layer versions in your account
import boto3
# if you use a separate profile for layers
session = boto3.Session(profile_name='LayerUploader')
regions = ['ap-northeast-1', 'ap-northeast-2', 'ap-south-1',
'ap-southeast-1', 'ap-southeast-2', 'ca-central-1',
'eu-central-1', 'eu-north-1', 'eu-west-1',
'eu-west-2', 'eu-west-3', 'sa-east-1',
'us-east-1', 'us-east-2','us-west-1',
@keithrozario
keithrozario / test.js
Created November 22, 2018 16:06
bcrypt in node
const hash = '$2b$12$HcE9WPecLL0IxfWr2om3W.tBWxJTLAd.xpLWDz43oKaqfbxtnUTKm'
for (i = 0; i < 500; i++) {
const myPlaintextPassword = i.toString()
bcrypt.compare(myPlaintextPassword , hash, function(err, res) {
console.log(myPlaintextPassword)
})
}
@keithrozario
keithrozario / github_webhook.py
Created October 15, 2018 14:05
GitHub_WebHook
import boto3
import json
import hmac
import hashlib
from botocore.exceptions import ClientError
headers = {'Access-Control-Allow-Origin': '*'} # CORS
def get_secret():