kreuzwerker / awsu

Enhanced account switching for AWS, supports Yubikey as MFA source
GNU General Public License v3.0
175 stars 16 forks source link

Create EC2 metadata API proxy for local container development #33

Closed yawn closed 4 years ago

yawn commented 5 years ago

The use case looks like this: for local container based development you need to export (and very often re-export) environment variables into it (at least key id, secret key and session id). An alternative would be to add a port directive to the shared configuration files and forward these ports to the dedicated container specific ports for the metadata API.

The local setup would then require the setup from https://github.com/NYTimes/mock-ec2-metadata:

/sbin/ifconfig lo:1 inet 169.254.169.254 netmask 255.255.255.255 up
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A OUTPUT -p tcp -d 169.254.169.254/32 --dport 80  -j DNAT --to-destination 169.254.169.254:65432
service iptables save

With the local ports configured awsu would get another command e.g. listen. This would basically invoke the port-appropriate assuming of roles etc., re-using (and re-writing) the same cached files as awsu does right now. This would also require locking on the FS level.