Skip to content

Instantly share code, notes, and snippets.

@crabba
Created August 26, 2023 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crabba/389749bc8b7307a44aac87fe36c46165 to your computer and use it in GitHub Desktop.
Save crabba/389749bc8b7307a44aac87fe36c46165 to your computer and use it in GitHub Desktop.
Detect OS and set useful variables
#! /bin/bash
# Detect OS and set useful environment variables
# Sets:
# AWS_ACCOUNT_ID
# AWS_REGION
TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
curl http://169.254.169.254/latest/meta-data/profile -H "X-aws-ec2-metadata-token: $TOKEN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment