Skip to content

Instantly share code, notes, and snippets.

View buptzhoutian's full-sized avatar

buptzhoutian buptzhoutian

View GitHub Profile
@Lowess
Lowess / .pre-commit-config.yaml
Last active September 23, 2023 11:34
Jinja2 template to auto-generate atlantis.yaml for Atlantis / Terraform & pre-commit action & shell script
repos:
- repo: https://github.com/lowess/pre-commit-hooks
rev: v1.2.0 # Get the latest from: https://github.com/lowess/pre-commit-hooks/releases
hooks:
- id: jinja2-render-template
name: Render atlantis.yaml configuration
args:
- atlantis.j2
- --output
- atlantis.yaml
@lukeplausin
lukeplausin / bash_aws_jq_cheatsheet.sh
Last active July 15, 2024 09:10
AWS, JQ and bash command cheat sheet. How to query, cut and munge things in JSON generally.
# Count total EBS based storage in AWS
aws ec2 describe-volumes | jq "[.Volumes[].Size] | add"
# Count total EBS storage with a tag filter
aws ec2 describe-volumes --filters "Name=tag:Name,Values=CloudEndure Volume qjenc" | jq "[.Volumes[].Size] | add"
# Describe instances concisely
aws ec2 describe-instances | jq '[.Reservations | .[] | .Instances | .[] | {InstanceId: .InstanceId, State: .State, SubnetId: .SubnetId, VpcId: .VpcId, Name: (.Tags[]|select(.Key=="Name")|.Value)}]'
# Wait until $instance_id is running and then immediately stop it again
aws ec2 wait instance-running --instance-id $instance_id && aws ec2 stop-instances --instance-id $instance_id
# Get 10th instance in the account