I hereby claim:
- I am laycat on github.
- I am laycat (https://keybase.io/laycat) on keybase.
- I have a public key ASBvWoGV2Cy5TBFEZd5wSba_Sk_bh7nvepo3EavsP53piwo
To claim this, I am signing this object:
import hvac | |
def move_secret(old_path, new_path, client=None, delete=False): | |
if not client: | |
client = hvac.Client() | |
response = client.secrets.kv.v1.read_secret(path=old_path) | |
response = client.secrets.kv.v1.create_or_update_secret(path=new_path, secret=response['data']) |
# aws s3 cp s3://path/to/terraform.tfstate tmp/ | |
jq -r '.modules[].resources | keys[]' tmp/terraform.tfstate |\ | |
grep '^aws_' |\ | |
while read line | |
do | |
echo "%% $line" | |
jq -r ".modules[].resources[\"$line\"].primary.id" tmp/terraform.tfstate | |
done |\ | |
grep -v null |
function get-instances() { | |
name=$1 | |
( | |
echo 'Name,PrivateIPAddress,State,LaunchTime (↓)' &&\ | |
aws ec2 describe-instances --filters "Name=tag:Name,Values=$name" |\ | |
jq -r '.Reservations[].Instances[] | | |
["\(.Tags | map(select(.Key == "Name").Value)[0])-\(.InstanceId)", .PrivateIpAddress, .State.Name, .LaunchTime] | | |
@csv' |\ | |
tr -d '"' |\ | |
sort -k 4 |
# E.g. Terraform IAM policies | |
terraform plan |\ | |
grep ' policy: ' |\ | |
sed 's/ *policy: *"\(.*\)" => "\(.*\)"/FROM\n\1\n%\nTO\n\2\n%/' |\ | |
sed 's/\\n/\n/g' | sed 's/\\"/"/g' |\ | |
gsplit -d -l 1 -t % - diff && \ | |
diff -y diff00 diff01 && \ | |
rm diff0* |
# Save output of AWS STS Assume Role to temporary credentials file for further use | |
aws sts assume-role --role-arn arn:aws:iam::12345:role/role_to_assume --role-session-name laycat-session |\ | |
jq '.Credentials | "[default] | |
aws_access_key_id=\(.AccessKeyId) | |
aws_secret_access_key=\(.SecretAccessKey) | |
aws_session_token=\(.SessionToken) | |
"' | xargs printf > ~/.aws/tmp |
ASG=asg1 aws ec2 describe-instances --filters "Name=tag:aws:autoscaling:groupName,Values=$ASG" |\ | |
jq '.Reservations[].Instances[] | [.InstanceId, (.Tags | map(select(.Key == "Name").Value)[0]), .State.Name]' |
# bastion host for env1 | |
Host env1 | |
Hostname 1.2.3.4 | |
User laycat | |
ForwardAgent yes | |
# Same user, simple pattern matching, allows `ssh host1.env1.fq.dn` from local host | |
Host *.env1.fq.dn | |
User laycat | |
ProxyCommand ssh -q env1 -W %h:22 |
I hereby claim:
To claim this, I am signing this object:
# display VPC ID, CIDR Block and Name | |
aws ec2 --output text --query 'Vpcs[*].{VpcId:VpcId,Name:Tags[?Key==`Name`].Value|[0],CidrBlock:CidrBlock}' describe-vpcs |
#!/bin/sh | |
# export-settings | |
# echos all gnome-terminal dconf settings for the first gnome-terminal profile | |
# the idea is you'll direct the output of this to somewhere to be consumed by | |
# import-settings | |
# note: I have no idea what the order of the profiles list is. I only have one | |
# profile, so don't really care either | |
profile_id=$(dconf list /org/gnome/terminal/legacy/profiles:/ | head -1) |