Some examples for AWS
EC2
Get a list of EC2 instances where we use a filter to query (tag with value PROD), only want the output of instanceId, PublicDnsName and the Name and present it in a table:
aws ec2 describe-instances --filters Name=tag-value,Values=PROD --query "Reservations[*].Instances[*].{Instance:InstanceId,PublicDnsName:PublicDnsName,Name:Tags[?Key=='Name']|[0].Value}" --output table
Delete all unused security groups (github source here):
#!/usr/bin/env bash # lists all unused AWS security groups. # a group is considered unused if it's not attached to any network interface. # requires aws-cli and jq. # all groups aws ec2 describe-security-groups \ | jq --raw-output '.SecurityGroups[] | [.GroupName, .GroupId] | @tsv' \ | sort > /tmp/sg.all # groups in use aws ec2 describe-network-interfaces \ | jq --raw-output '.NetworkInterfaces[].Groups[] | [.GroupName, .GroupId] | @tsv' \ | sort \ | uniq > /tmp/sg.in.use diff /tmp/sg.all /tmp/sg.in.use |grep "<" |cut -d ' ' -f2-3
Cert Manager
Get the public certificate:
aws acm get-certificate --certificate-arn arn:aws:acm:eu-central-1:XXXX:certificate/YYYYYYY > output.json
Cognito
Create a user and skip the force password change flow
aws cognito-idp admin-set-user-password --user-pool-id XXXXX --username YYYYY --password ZZZZZ --permanent