Skip to content

Instantly share code, notes, and snippets.

View lucidaeon's full-sized avatar
☁️
reading whitepapers

Lucid ⚡ lucidaeon

☁️
reading whitepapers
View GitHub Profile
@lucidaeon
lucidaeon / gist:81be12b55b86d29b6813b93f88e06099
Created July 23, 2021 20:24
aws ec2 describe-instances | jq for all running hosts matching a certain name
aws ec2 describe-instances | jq -r --arg match "${1}" '.Reservations[]|select(.Instances[]|select((.Tags[]|select(.Key=="Name")|.Value)|match($match)))|select(.Instances[]|select(.State|select(.Name=="running")))|.Instances[].PrivateIpAddress'
@lucidaeon
lucidaeon / gist:b7b328f41a6b59eaf5e8d511f5af25a3
Created March 27, 2021 03:17
Synology DSM stop all services
for svc in $(synoservicecfg --list|egrep -iv perl\|ssh)
do
synoservice --stop "${svc}"
done
@lucidaeon
lucidaeon / put-bucket-lifecycle-configuration.json
Created August 25, 2020 19:20
Empty an Amazon S3 bucket using a lifecycle configuration rule
{
"Rules": [
{
"Expiration": {
"Days": 1
},
"ID": "expire current versions of objects and permanently delete previous versions of objects",
"Filter": {
"Prefix": ""
},

Keybase proof

I hereby claim:

  • I am laurentr on github.
  • I am laurentr (https://keybase.io/laurentr) on keybase.
  • I have a public key ASDPfH4-B29Eey16Kxn_lBVTnrxd2PYuMXb-o42lF5CPHAo

To claim this, I am signing this object:

@lucidaeon
lucidaeon / gist:e79d399e2bdbb489b884c4e39a41c529
Created August 10, 2017 18:43
set AWS STS / MFA environment variables if current session is valid
# OSX
[[ "$(( $(date +"%s") - $(stat -f "%m" ~/.aws/mfa_credentials) ))" -lt "43200" ]] && eval $(aws-mfa)
# Linux
[[ "$(( $(date +"%s") - $(stat -c "%Y" ~/.aws/mfa_credentials) ))" -lt "43200" ]] && eval $(aws-mfa)
@lucidaeon
lucidaeon / gist:77741816ca4b77a3096343e4f9a0fa16
Created June 21, 2017 19:23
awscli + jq get latest AMI
# if you produce AMIs with naming such as $prefix-$timestamp
aws ec2 describe-images --owners self --filters Name=name,Values=PREFIX* --query 'Images[?State==`available`]' | jq -r '.=sort_by(.CreationDate)|.[-1].ImageId'