Skip to content

Instantly share code, notes, and snippets.

View shollingsworth's full-sized avatar

Steven Hollingsworth shollingsworth

  • SkySafe.io
  • United States
  • X @_stevo
View GitHub Profile
@shollingsworth
shollingsworth / iam_githubactions.tf
Created April 5, 2023 21:07
terraform starter file to configure AWS with github actions
resource "aws_iam_openid_connect_provider" "github_actions" {
client_id_list = ["sts.amazonaws.com"]
thumbprint_list = ["6938fd4d98bab03faadb97b34396831e3780aea1"]
url = "https://token.actions.githubusercontent.com"
}
data "aws_iam_policy_document" "github_actions_assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
@shollingsworth
shollingsworth / github.ts
Last active April 5, 2023 17:55
cdk v2 github provider and role template for github actions cloudformation
import * as iam from "@aws-cdk/aws-iam";
import * as cdk from "@aws-cdk/core";
import * as aws_ssm from "@aws-cdk/aws-ssm";
import { Config } from "../config";
function chunk(arr: Array<any>, chunkSize: number) {
if (chunkSize <= 0) throw "Invalid chunk size";
var R = [];
for (var i = 0, len = arr.length; i < len; i += chunkSize)
R.push(arr.slice(i, i + chunkSize));
@shollingsworth
shollingsworth / demo.tf
Created March 31, 2023 20:58
Starter main.tf for terraform state files only in AWS using s3 bucket and dynamoDB
provider "aws" {
region = "us-east-2"
default_tags {
tags = {
tag1 = "value1"
tag2 = "value2"
}
}
}
@shollingsworth
shollingsworth / git-modified-files.py
Created October 27, 2022 13:40
List git modified files for use in something like vim.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""List git modified files for use in something like vim."""
import subprocess
def main():
"""Run main function."""
edit_keys = {
"A",
@shollingsworth
shollingsworth / convert_jq_key_value_to_aws_tags_array.sh
Last active September 14, 2022 00:17
AWS tags - convert a json key value {"foo": "bar", "baz": "qux"} to [{ "Key": "foo", "Value": "bar"}, {"Key": "baz", "qux"}]
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
TAGS_JSON=$(
cat <<EOF
{
"foo": "bar",
"baz": "qux"
}
@shollingsworth
shollingsworth / rewrite.py
Created August 15, 2022 19:50
threaded aws s3 bulk object modify and move
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""bulk object modify and move."""
import concurrent.futures as cf
import json
import boto3
from mypy_boto3_s3.service_resource import Bucket, ObjectSummary
BUCKET_NAME = "some-bucket"
@shollingsworth
shollingsworth / .00README.md
Last active August 10, 2022 23:45
Scaffold for serverless directory with layer, log retention, and http wildcard http api gateway

Scaffold for serverless directory with layer, log retention, and http wildcard http api gateway

Deploy

  • Run yarn
  • Edit ./config.yaml as needed
  • Edit ./serverless.yml as needed
  • Run make build
  • Run make deploy

Delete

@shollingsworth
shollingsworth / Makefile
Last active August 9, 2022 03:36
go makefile to compile multiple platforms / architectures
.DEFAULT_GOAL := help
GOARCH := amd64
PROJECT := github.com/shollingsworth
PREFIX := stil
BUILD_DIR := build
# Run go tool dist list to see all os & arch combinations that are supported.
GOOS := linux # put other OSes here as needed
ARCH := amd64 # what architectures to build for
ENTRYPOINT := main.go
@shollingsworth
shollingsworth / .00_README.md
Last active August 6, 2022 05:54
Get a Reverse Shell with Only egress tcp/443 (i.e. AWS Training Environments)

Prep

  • Download the zip ^ in this gist and unzip into a project directory.
  • On your home internet gateway, port forward 443 to your internal ip port 2222

Instructions


  • Remote
@shollingsworth
shollingsworth / common_strings_multiple_files.py
Created July 13, 2022 00:42
Find common strings in multiple files
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Find common strings in multiple files."""
import argparse
from io import BytesIO
from pathlib import Path
import tokenize
def _itertokens(file: Path):