AWS EC2 Metadata viewer using Nginx Docker Image
This one is just a hobby docker image to view/ look out for the ec2 instance’s metadata using a UI/ html hosted inside/ via nginx docker image.
While managing the AWS ec2 instances checking the instance metadata via curl is very manual and very repetitive work. So to fetch the same using some UI would be very easy for most us.
So here I was with the same challenge of removing the unwanted repeated stuff via curls and commands.
Prerequisites
AWS knowledge, AWS ec2 instance, etc. ❕
Docker installed on ec2 instance (obviously) ❕
⚠️Be Aware of the fact that your metadata will be available over web via html. As exposing/ sharing metadata might be security threat. (for hobby purpose or private ips it might be ok or public ip with proper security group etc.)
❗️ Metadata v1 for ec2. Extra work would certainly be required to expose v2 (that is based on tokens etc. and provides extra security over the metadata v1)
The Docker image can be accessed using the pull command as below:-
docker pull neuw/aws-ec2-nginx
Source code of the same is here available on Github
For Running the command the container the command is like below:-
docker run -itd --name nginx -p 80:80 neuw/aws-ec2-nginx
And after the UI will be available at :-
http://machine_host_or_ip:port/metadata.html
Replace hostname or ip and port accordingly
And UI should be available as below by default
In the first input box you can change the url to /latest/** and it will show you response accordingly.
Example:- /latest/meta-data
Further one may use the following user-data script while bootstrapping the ec2 instance(applicable for the AWS Linux 2 AMI only), details below:-
#!/bin/sh
yum update
# install docker and start the docker service
yum install docker -y
service docker start
# add ec2-user to the docker group
usermod -a -G docker ec2-user
# pull the image that was mentioned above
docker pull krnbr/ec2-nginx:latest
# run the same image as a container available on host's port 80
docker run -itd --name nginx -p 80:80 neuw/aws-ec2-nginx
Change port 80 to something more specific - And this image can run as sidecar to your other images, for debug purpose in lower environments
Top comments (0)