NYTimes/mock-ec2-metadata

Name: mock-ec2-metadata

Owner: The New York Times

Description: null

Created: 2016-06-21 19:52:40.0

Updated: 2018-04-10 20:41:00.0

Pushed: 2017-06-02 18:30:03.0

Homepage: null

Size: 25

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

mock-ec2-metadata Build Status

A simple service (written in go using gizmo) to mock the ec2 metadata service. This is usefully for development images (like vagrant or packer) that require Instance base IAM permission or other metadata information.

For example, cob and s3-iam can both use s3 as a yum repo. Both of these systems rely on the instances the proper credentials to have authorization to the s3 repos that yum uses.

The metadata service normal listens on a special private ip address 169.254.169.254. This is a special address that will not exist on your system. One option is to bind an alias to the loopback iterface. This can be done with the following command:

n/ifconfig lo:1 inet 169.254.169.254 netmask 255.255.255.255 up

Many services assume that use the metadata service uses a default port 80 and do not allow configuration or override. A simple IP talbes rule and IP forwarding can get around that, as follows:

ho 1 > /proc/sys/net/ipv4/ip_forward
tables -t nat -A OUTPUT -p tcp -d 169.254.169.254/32 --dport 80  -j DNAT --to-destination 169.254.169.254:8111
rvice iptables save
Configuration

All configuration is contained in either ./mock-ec2-metadata-config.json or /etc/mock-ec2-metadata-config.json, the former overriding the latter.

Currently the support URLs for the metadata service are:

Getting started

This project requires Go to be installed. On OS X with Homebrew you can just run brew install go.

Running it then should be as simple as:

ke
bin/mock-ec2-metadata
Testing

make test

License

See LICENSE

Contributing

See CONTRIBUTING.md for more details.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.