AWS Metadata as Environment Variables
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore Initial Mar 16, 2018
Dockerfile
LICENSE
Makefile
README.md Adds systemd unit Mar 16, 2018
aws-env.service
main.go Adds 'export' Mar 16, 2018

README.md

cmattoon/aws-env

Exports AWS meta-data as environment vars

docker pull cmattoon/aws-env:latest

Example Output

AMI_ID="ami-xxxxxx"
AMI_LAUNCH_INDEX="0"
AMI_MANIFEST_PATH="(unknown)"
HOSTNAME="ip-172-1-1-1.us-west-2.compute.internal"
INSTANCE_ACTION="none"
INSTANCE_ID="i-xxxxxxxxxxxxxxx"
INSTANCE_TYPE="t2.medium"
LOCAL_HOSTNAME="ip-172-1-1-1.us-west-2.compute.internal"
LOCAL_IPV4="172.1.1.1"
MAC="aa:bb:cc:dd:ee:ff"
AVAILABILITY_ZONE="us-west-2a"
PROFILE="default-hvm"
PUBLIC_HOSTNAME="ec2-2-2-2-2.us-west-2.compute.amazonaws.com"
PUBLIC_IPV4="2.2.2.2"
RESERVATION_ID="r-xxxxxxxxxxxxx"
SECURITY_GROUPS="TestSecurityGroup"

Use Case: Eval to set Environment

eval $(docker run --rm -t cmattoon/aws-env:latest)

Use Case: Write Environment File

docker run --rm -e AWS_ENVIRONMENT_FILE=/foo/aws.env -v /tmp:/foo -t cmattoon/aws-env:latest

Use Case: Add Environment File on Startup with Systemd

  • sudo cp aws-env.service /etc/systemd/system/aws-env.service
  • sudo systemctl daemon-reload
  • sudo systemctl start aws-env

Build

make container