Skip to content

Instantly share code, notes, and snippets.

View wparad's full-sized avatar
🇨🇭
I solve security in SaaS.

Warren Parad wparad

🇨🇭
I solve security in SaaS.
View GitHub Profile
{
"StartAt": "Start",
"States": {
"Start": {
"Type": "Task",
"Resource": { "Ref": "LambdaFunctionProductionAlias" },
"Parameters": {
"context.$": "$$",
"parameters.$": "$"
},
@wparad
wparad / rds_ssm_tunnel.sh
Last active November 18, 2021 20:57
Tunnel to RDS through a SSM connection to an EC2 bastion on jumpbox
#!/bin/bash
## Sourced from: https://www.reddit.com/r/aws/comments/df6uip/comment/f85pcoy/?utm_source=share&utm_medium=web2x&context=3
# Help text
help()
{
echo ""
echo " -o | --override Override port forwarding values."
echo " Syntax:[local port] [remote host address] [remote port]"
@wparad
wparad / aws_vpn.tf
Last active January 10, 2022 17:23
Creates an AWS Client VPN with security groups given a VPC
locals {
environment = "dev",
vpc = {
vpc_id = "VPC_ID",
private_subnets = ["SUBNET_ID_1"]
}
}
resource "aws_cloudwatch_log_group" "vpn_cloudwatch_log_group" {
@wparad
wparad / findDanglingElasticIpAddresses.js
Last active October 3, 2021 17:32
Find Route53 records pointing to unowned IP Addresses
// This is also a config rule: https://eu-west-2.console.aws.amazon.com/lambda/home?region=eu-west-2#/create/app?applicationId=arn:aws:serverlessrepo:eu-west-1:922723803004:applications/Elastic-IP-Config-Rule
const { Route53, EC2, config } = require('aws-sdk');
config.region = 'eu-west-1';
async function findDanglingElasticIpAddresses(dryRun = true) {
const route53 = new Route53();
let hostedZoneIds;
try {
console.log('Looking up hosted zones:');
@wparad
wparad / slackHaProxyErrorResponse.js
Last active September 24, 2021 08:17
Slack conversations.history not found error (linked)
{
headers: {
date: 'Tue, 15 Sep 2020 04:16:02 GMT',
server: 'Apache', 'content-length': '223',
'x-via': 'haproxy-www-xfba,haproxy-edge-dub-73iu',
'content-type': 'text/html; charset=iso-8859-1'
},
data: `<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
@wparad
wparad / enable-vpn.sh
Created July 25, 2021 19:56
Enable/Disable VPN by a push of a button
#!/usr/bin/env bash
currentState=`nmcli connection | grep SeedBox | tr -s ' ' | cut -f4 -d' '`
if [ "${currentState}" = "--" ]
then
nmcli connection up SeedBox
#service firewalld start
else
@wparad
wparad / run-or-raise.js
Last active June 30, 2021 10:41
Alt Tab Plus - Find a selected programming running and focus it, or start it if it doesn't exist
#!/usr/bin/env node
const util = require('util');
const { spawn: spawnAsync, exec } = require('child_process');
const execAsync = util.promisify(exec);
const fs = require('fs').promises;
// Remove first two args with are name of node, and name of file
process.argv.shift();
process.argv.shift();
@wparad
wparad / cloudfront-logging-cfn-template.json
Created April 7, 2021 17:00
Cloudformation template to log requests from CloudFront to S3 and trigger a Lambda to process them.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Store and process user surveys",
"Parameters": {
"serviceName": {
"Type": "String",
"Description": "The name of the microservice"
},
"deploymentBucketName": {
"Type": "String",
@wparad
wparad / responsive-toolkit.js
Last active October 5, 2021 10:19
Reactive javascript triggered by bootstrap media queries
const xs = document.createElement('div');
xs.setAttribute('class', 'd-inline d-sm-none');
const sm = document.createElement('div');
sm.setAttribute('class', 'd-none d-sm-inline d-md-none');
const md = document.createElement('div');
md.setAttribute('class', 'd-none d-md-inline d-lg-none');
const lg = document.createElement('div');
@wparad
wparad / .aws-config
Last active November 21, 2020 09:57
Default AWS configuration
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html
[default]
region=us-east-1
output=json
cli_binary_format=raw-in-base64-out
cli_auto_prompt = on