Skip to content


AWS CLI & Metadata🔗

Retrieve Instance Region🔗

Looks like the metadata service uses tokens now, so this requires an additional step.

TOKEN=`curl --silent --show-error --fail -X PUT "" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`
RESPONSE=`curl --silent  --show-error --fail -H "X-aws-ec2-metadata-token: $TOKEN"`
echo "Current Region is: [$RESPONSE]"

List Matching Instances🔗

You can use output with --output text but for this example I used json and jq.

aws ec2 describe-instances --filters "Name=tag:Name,Values={{ .EC2_NAME_FILTER }}" --output json \
--query 'Reservations[*].Instances[*].{Instance:InstanceId}' | jq --compact-output '.[][].Instance'

List Standard Users🔗

getent passwd {1000..60000}

Last update: 2023-09-16
Created: 2023-09-16