An Interest In:
Web News this Week
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
- April 19, 2024
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
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/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
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To