Skip to content

Instantly share code, notes, and snippets.

Avatar

Josh Padnick josh-padnick

View GitHub Profile
@josh-padnick
josh-padnick / README.md
Last active Aug 11, 2020
Manually Edit AWS Console "Switch Role" Configuration in Bash
View README.md

Manually Edit AWS Console "Switch Role" Configuration in Bash

Motivation

At Gruntwork, we work with multiple software teams. That means we have to modify the "Switch Role" history multiple times. But the only way to do that today is to delete your cookie and clear all AWS Console saved settings. That got old after a while, so these instructions enable you to modify the "Switch Roles" configuration directly.

The Big Picture

@josh-padnick
josh-padnick / download.sh
Last active Jul 29, 2020
Download a private binary release file from GitHub in bash
View download.sh
#!/usr/bin/env bash
#
# This is an adaptation of code I wrote to download a private binary from GitHub. Such...pain.
# Why can't GitHub just offer a standardized URL you can download a release binary from and attach
# your Github Personal Access Token as a header?
#
# Since this code is an adaptation it hasn't been directly tested, but the code it was adapted from works
# and hopefully you can get the missing piece you're after by looking here.
#
@josh-padnick
josh-padnick / get-latest-terraform.sh
Created Mar 28, 2016
Auto-update to latest version of Terraform
View get-latest-terraform.sh
#!/bin/bash
LATEST_RELEASE=$(curl https://api.github.com/repos/hashicorp/terraform/releases/latest | jq --raw-output '.tag_name' | cut -c 2-)
if [[ ! -e ${LATEST_RELEASE} ]]; then
echo "Installing Terraform ${LATEST_RELEASE}..."
rm terraform-*
rm terraform
wget https://releases.hashicorp.com/terraform/${LATEST_RELEASE}/terraform_${LATEST_RELEASE}_linux_amd64.zip
unzip terraform_${LATEST_RELEASE}_linux_amd64.zip
rm terraform_${LATEST_RELEASE}_linux_amd64.zip
@josh-padnick
josh-padnick / fish-agent.sh
Last active Jun 27, 2020
Run ssh-agent via fish shell
View fish-agent.sh
#!/bin/bash
#
# Convert ssh-agent output to fish shell
#
eval "$(ssh-agent)" >/dev/null
echo "set SSH_AUTH_SOCK \"$SSH_AUTH_SOCK\"; export SSH_AUTH_SOCK"
echo "set SSH_AGENT_PID \"$SSH_AGENT_PID\"; export SSH_AGENT_PID"
View get-latest-terraform.sh
#!/bin/bash
#
# If there's a new Terraform releases available, delete the current Terraform install and download the new one.
# Must be run from within the directory where terraform binaries should reside
#
LATEST_RELEASE=$(curl https://api.github.com/repos/hashicorp/terraform/releases/latest | jq --raw-output '.tag_name' | cut -c 2-)
if [[ ! -e ${LATEST_RELEASE} ]]; then
echo "Installing Terraform ${LATEST_RELEASE}..."
rm terraform-*
@josh-padnick
josh-padnick / crontab file
Last active Nov 16, 2019
Create EC2 AMI from Bash Script; Good for cron jobs
View crontab file
PATH=/bin:/usr/local/bin
# Put this in your crontab file to run the script every day at 01:30 (1:30am). Note the PATH variable above; required for this script.
# m h dom mon dow command
30 01 * * * /bin/bash /home/ubuntu/scripts/ec2-create-image.sh i-8a915682 >> /home/ubuntu/logs/crontab.log 2>&1
View gist:a0ae497d19508c9512018d8b2c9e17d8
=== RUN TestOsHardeningXFS
TestOsHardeningXFS 2018-11-21T06:02:13Z region.go:72: Looking up all AWS regions available in this account
TestOsHardeningXFS 2018-11-21T06:02:15Z region.go:57: Using region ap-northeast-2
TestOsHardeningXFS 2018-11-21T06:02:15Z key_pair.go:31: Generating new public/private key of size 2048
TestOsHardeningXFS 2018-11-21T06:02:20Z keypair.go:49: Creating new Key Pair in EC2 region ap-northeast-2 named AAsSgo
TestOsHardeningXFS 2018-11-21T06:03:08Z command.go:52: Running command ./packer-build.sh with args [-var ami_module_security_version_type="branch" -var vpc_id="vpc-32e3025b" -var should_create_keypair="0" -var aws_region="ap-northeast-2" -var ami_builder_source_ami="ami-0076ae0908f382581" -var ami_builder_source_ami_ssh_username="ec2-user" -var ami_ebs_volume_size="25" -var ami_github_oauth_token="<REDACTED>" -var ami_partition_fs_type="xfs" -var ami_module_security_version="master" -var ami_builder_keypair_private_key="-----BEGIN RSA PRIVATE KEY-----\nREDACTED\n-----END RSA PR
@josh-padnick
josh-padnick / example
Last active Nov 12, 2018
Terraform here doc syntax example
View example
user_data = <<-EOF
#!/bin/bash
echo "hello world" > index.html
nohup busybox httpd -f -p "8080" &
EOF
@josh-padnick
josh-padnick / confluent-main.tf
Created Jun 3, 2018
Terraform Module depends_on, Part Deux
View confluent-main.tf
# This file should be at /confluent/main.tf
variable "kafka_cluster_deployment_done" {}
module "confluent_tools" {
source = "../server-group/"
rolling_deployment_done = "${var.kafka_cluster_deployment_done}"
}
@josh-padnick
josh-padnick / tf-bar.tf
Last active May 31, 2018
Hack for Terraform Module depends_on
View tf-bar.tf
# This file would need to be in its own folder like /tf-bar/main.tf
variable "bar" {
default = "foo"
}
resource "null_resource" "bar" {
triggers {
bar = "${var.bar}"
}
You can’t perform that action at this time.