Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
August 28, 2022 06:27 pm GMT

AWS EC2 Metadata viewer usingNginx

AWS EC2 Metadata viewer using Nginx Docker Image

This one is just a hobby docker image to view/ look out for the ec2 instances 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/shyum update# install docker and start the docker serviceyum install docker -yservice docker start# add ec2-user to the docker groupusermod -a -G docker ec2-user# pull the image that was mentioned abovedocker pull krnbr/ec2-nginx:latest# run the same image as a container available on host's port 80docker 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


Original Link: https://dev.to/aws-builders/aws-ec2-metadata-viewer-using-nginx-3jgo

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To