Skip to content

Instantly share code, notes, and snippets.

View nitrocode's full-sized avatar
🚀
Thinking and typing

nitrocode nitrocode

🚀
Thinking and typing
View GitHub Profile
@nitrocode
nitrocode / github-gpg-key-with-private-email.md
Last active June 19, 2024 00:01
Github "Verified" commits using GPG key with private email

Github "Verified" commits using GPG key with private email

It's nice to see a Verified message next to each commit for peace of mind.

Using GPG or S/MIME, you can sign tags and commits locally. These tags or commits are marked as verified on GitHub so other people can be confident that the changes come from a trusted source.

  1. Install latest gpg

    If using a mac use homebrew

@nitrocode
nitrocode / template-terraform-provider-for-darwin-arm.md
Last active February 12, 2024 22:58
Template terraform provider for darwin arm

Template terraform provider for darwin arm

Provider registry.terraform.io/hashicorp/template v2.2.0 does not have a package available for your current platform, darwin_arm64

why

The templatefile function only works with files. If you're working with files then switch to templatefile.

The hashicorp/template provider's template_file data source works with template strings and files (converted to strings) but was archived/deprecated before creating an arm release forcing people to look into other options if using Apple M1 (based on ARM).

@nadirollo
nadirollo / copy_tags.py
Created February 25, 2021 15:57
python script to copy tags from a packer build into different accounts
#!/usr/bin/env python
import boto3
import os
import json
script_dir = os.path.dirname(os.path.realpath(__file__))
owner_account = 'xxxxxxxxxxx'
@pjaudiomv
pjaudiomv / update-ssm-tags.sh
Created October 1, 2020 14:11
Tags instances with detected platform and patch group
#!/bin/bash
INSTANCE_IDS=$(aws ssm describe-instance-information --query 'InstanceInformationList[?starts_with(InstanceId, `i-`) == `true` && starts_with(PingStatus, `Online`) == `true`].InstanceId' --output json)
# we don't wan't instances that start with m as they are not taggable, usually workspaces. We also will only tag instances that are online.
export INSTANCE_IDS
echo "Instances that are going to be updated: $INSTANCE_IDS"
echo "$INSTANCE_IDS" | jq -r '.[]' | while read INSTANCE; do
PLATFORM_NAME=$(aws ssm describe-instance-information --instance-information-filter-list key=InstanceIds,valueSet=$INSTANCE --output text --query 'InstanceInformationList[].PlatformName')
PLATFORM_VER=$(aws ssm describe-instance-information --instance-information-filter-list key=InstanceIds,valueSet=$INSTANCE --output text --query 'InstanceInformationList[].PlatformVersion')
@michalstala
michalstala / sorting-aws-cli-describe-images-output.md
Created October 3, 2018 09:54
How to sort AWS CLI describe-images output using jd

As an example query AWS for a list of all NAT Instance AMIs:


aws ec2 describe-images --filter Name="owner-alias",Values="amazon" --filter Name="name",Values="amzn-ami-vpc-nat*" --region us-west-2 | jq '.Images | sort_by(.CreationDate)'

If only specific fields are required to print into output:

@dstokes
dstokes / dns-check.sh
Created November 7, 2016 23:53
Test Dead Route53 DNS Records
#!/bin/bash
DOMAIN=$1
PORT=$2
TYPES=(A CNAME)
# resolve zone id
ZONE=$(aws route53 list-hosted-zones --query 'HostedZones[?Name==`'$DOMAIN'.`].Id' --output text)
if [[ -z "$ZONE" ]]; then
echo "Unrecognized domain: $1" >&2
@michaelgrosser
michaelgrosser / vagrantfile.rb
Last active November 7, 2017 11:11
Share Host AWS Credentials with Vagrant Guest
# Copy AWS credentials and config from host to guest
$aws_credentials_path = ENV['HOME'] + "/.aws/credentials"
$aws_config_path = ENV['HOME'] + "/.aws/config"
if File.file?($aws_credentials_path) && File.file?($aws_config_path) then
config.vm.provision "shell",
inline: "mkdir -p /root/.aws",
privileged: true
config.vm.provision "shell",
inline: "mkdir -p /home/nginx/.aws",
@tomysmile
tomysmile / brew-java-and-jenv.md
Last active April 20, 2022 16:14
How To Install Java 8 on Mac

Install HomeBrew first

brew update
brew tap caskroom/cask
brew install brew-cask

If you get the error "already installed", follow the instructions to unlink it, then install again:

@hummus
hummus / gist:8592113
Last active April 26, 2024 19:45
aws cli + jq example
wget http://stedolan.github.io/jq/download/linux64/jq
aws ec2 describe-instances --filters "Name=tag:Name,Values=$NAME" \
"Name=instance-state-name,Values=running" \
| jq -r \
".Reservations[] | .Instances[] | .InstanceId" \
aws ec2 describe-volumes --filters \
"Name=status,Values=available" \
| jq -r ".Volumes[] | .VolumeId" \
@nateswart
nateswart / com.nateofnine.FlaggedEmailToReminder.plist
Created January 9, 2014 03:54
plist to run this AppleScript every minute via launchd
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>com.nateofnine.FlaggedMailToReminders</string>
<key>Program</key>
<string>/usr/bin/osascript</string>