Skip to content

Instantly share code, notes, and snippets.

Josh Padnick josh-padnick

Block or report user

Report or block josh-padnick

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@josh-padnick
josh-padnick / download.sh
Last active Oct 10, 2019
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 / fish-agent.sh
Last active Oct 3, 2019
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"
@josh-padnick
josh-padnick / crontab file
Last active Mar 25, 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 / 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 / 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}"
}
View gist:ef1677c29600abfa1c87ef3060b737d7
josh@pad-mac ~/g/s/g/g/p/t/tf-modules (kafka-status-check)> terraform apply
2018/05/31 13:24:29 [INFO] Terraform version: 0.11.7 41e50bd32a8825a84535e353c3674af8ce799161
2018/05/31 13:24:29 [INFO] Go runtime version: go1.10.1
2018/05/31 13:24:29 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply"}
2018/05/31 13:24:29 [DEBUG] Attempting to open CLI config file: /Users/josh/.terraformrc
2018/05/31 13:24:29 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2018/05/31 13:24:29 [INFO] CLI command args: []string{"apply"}
2018/05/31 13:24:29 [TRACE] module source: "../tf-foo"
2018/05/31 13:24:29 [TRACE] module source: "../tf-bar"
2018/05/31 13:24:29 [INFO] command: empty terraform config, returning nil
View gist:4b2dc841475a482ce2d601df461e1c92
kafka-standalone-ubuntu 2018/03/30 11:35:29 Error: Error applying plan:
kafka-standalone-ubuntu 2018/03/30 11:35:29
kafka-standalone-ubuntu 2018/03/30 11:35:29 2 error(s) occurred:
kafka-standalone-ubuntu 2018/03/30 11:35:29
kafka-standalone-ubuntu 2018/03/30 11:35:29 * module.zookeeper.module.zookeeper_servers.aws_launch_configuration.server_group: aws_launch_configuration.server_group: diffs didn't match during apply. This is a bug with Terraform and should be reported as a GitHub Issue.
kafka-standalone-ubuntu 2018/03/30 11:35:29
kafka-standalone-ubuntu 2018/03/30 11:35:29 Please include the following information in your report:
kafka-standalone-ubuntu 2018/03/30 11:35:29
kafka-standalone-ubuntu 2018/03/30 11:35:29 Terraform Version: 0.11.5
kafka-standalone-ubuntu 2018/03/30 11:35:29 Resource ID: aws_launch_configuration.server_group
You can’t perform that action at this time.