AWS EC2 Metadata viewer using Nginx Docker Image

Karanbir Singh
3 min readSep 7, 2020

--

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

  1. AWS knowledge, AWS ec2 instance, etc. ❕
  2. Docker installed on ec2 instance (obviously) ❕
  3. ⚠️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.)
  4. ❗️ 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 neuw/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

For any further queries please post a reply on the story here or contact me on Linkedin here

--

--

Karanbir Singh
Karanbir Singh

Written by Karanbir Singh

API developer + Web Application developer + Devops Engineer = Full Stack Developer

No responses yet