Read a secret value aws
Fetch a JSON secret and extract one field. note: value appears in process args
aws secretsmanager get-secret-value --secret-id <name> --query SecretString --output text | jq -r '.password'
more aws
all 14 commands →
Cheapest spot price by AZ
aws ec2 describe-spot-price-history --instance-types m6i.large --product-descriptions 'Linux/UNIX' --start-time $(date -u +%Y-%m-%dT%H:%M:%S) --query 'sort_by(SpotPriceHistory,&SpotPrice)[0:5].[AvailabilityZone,SpotPrice]' --output table
Deploy CloudFormation stack
aws cloudformation deploy --template-file stack.yaml --stack-name <name> --capabilities CAPABILITY_NAMED_IAM --parameter-overrides Env=prod --no-fail-on-empty-changeset
Count results with JMESPath
aws ec2 describe-volumes --filters Name=status,Values=available --query 'length(Volumes[])' --output text --profile staging --region <id>
Who am I / which account
aws sts get-caller-identity --query '{acct:Account,arn:Arn}' --output table
Assume role and export creds
eval $(aws sts assume-role --role-arn <id> --role-session-name ops --query 'Credentials.[`AWS_ACCESS_KEY_ID=`+AccessKeyId,`AWS_SECRET_ACCESS_KEY=`+SecretAccessKey,`AWS_SESSION_TOKEN=`+SessionToken]' --output text | sed 's/^/export /')