Skip to content

Instantly share code, notes, and snippets.

@jayers99
jayers99 / Manage-R53RecordSet.ps1
Created June 10, 2018 20:53 — forked from lorengordon/Manage-R53RecordSet.ps1
PowerShell Script to Create/Delete/Update AWS Route53 Record Set
[CmdLetBinding()]
Param(
[Parameter(Mandatory=$true,ValueFromPipeLine=$false,ValueFromPipeLineByPropertyName=$true)]
[String] $HostedZoneId,
[Parameter(Mandatory=$true,ValueFromPipeLine=$false,ValueFromPipeLineByPropertyName=$true)]
[ValidateSet("CNAME","A","AAAA","MX","TXT","PTR","SRV","SPF","NS","SOA")]
[String] $Type,
[Parameter(Mandatory=$true,ValueFromPipeLine=$false,ValueFromPipeLineByPropertyName=$true)]
# reset my local to my origin
git fetch --all
git reset --hard origin/<branch>
# auto rebase conflicts
git rebase -X ours upstream/master
# -i case insensitive
# -l just show file path
# -r recursive
# -n line number
searchTerm=""
# just list the files containing search term
egrep -irl --include \*.tf --exclude-dir=.* "$searchTerm"
# to see the search term
# set a var name
mycertfile=<mycertfilename>
# to decrypt the private key
# this will ask you for a password
openssl pkey -outform PEM -in $mycertfile
# get all the nodes from pks file type
openssl pkcs12 -in $mycertfile -nodes
username=
sudo adduser $username
sudo su $username
cd ~
mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
# see all users
sudo cat /etc/shadow
# list all users with a password set to expire
sudo cat /etc/shadow | grep ':90:'
# cut out just the user name
sudo cat /etc/shadow | grep ':90:' | tr ':' ' ' | awk '{print $1}'
# put those users in a var
USER_LIST=$(sudo cat /etc/shadow | grep ':90:' | tr ':' ' ' | awk '{print $1}')
# loop through those users and set expiration really high
for i in $USER_LIST; do echo $i; sudo passwd -x 99999 $i; done
# -e regex
# -r extended regex
# -i in place replace (saves the file)
# adhoc string replace
sed -i 's/term/replace/' somefile.tf
# delete all lines containing
sed -i '/somestring/d' somefile.tf
# Terraform Troubleshooting
# keywords: trace, debug, verbose
# https://www.terraform.io/docs/internals/debugging.html
# TRACE, DEBUG, INFO, WARN or ERROR
export TF_LOG=WARN
export TF_LOG_PATH=./terraform.log
# Terraform State Move - Refactoring Terraform Against Existing Infrastructure
# https://ryaneschinger.com/blog/terraform-state-move/
terraform state mv aws_security_group.old_name aws_security_group.new_name
@jayers99
jayers99 / .bashrc
Last active February 9, 2019 17:45
# .bashrc
export PROMPT_COMMAND='history -a'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=