Last active
December 28, 2022 23:40
-
-
Save mohammad-quanit/4568258309e4f8012f4cf4bc8a33c956 to your computer and use it in GitHub Desktop.
Useful Commands & Scripts for AWS EC2 Service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# AWS EC2 Commands & Scripts | |
sudo su | |
yum update -y | |
**Getting metadata and other details of your ec2 instance** | |
curl http://169.254.169.254/latest/meta-data | |
curl http://169.254.169.254/latest/meta-data/ami-id | |
curl http://169.254.169.254/latest/meta-data/hostname | |
curl http://169.254.169.254/latest/meta-data/instance-id | |
curl http://169.254.169.254/latest/meta-data/instance-type | |
curl http://169.254.169.254/latest/dynamic | |
curl http://169.254.169.254/latest/dynamic/instance-identity | |
curl http://169.254.169.254/latest/dynamic/instance-identity/document | |
curl -s http://169.254.169.254/latest/dynamic/instance-identity/document > /var/www/html/index.html | |
*** Deafault Bootstraping script or user data for an EC2 instance launch *** | |
******************* FOR LINUX AMI **************** | |
#!/bin/bash | |
sudo su | |
yum update -y | |
yum install -y httpd | |
systemctl start httpd | |
systemctl enable httpd | |
chkconfig httpd on | |
cd /var/www/html | |
echo "<html><h1>This is server - 01 </h1></html>" > index.html | |
******************* FOR UBUNTU **************** | |
#!/bin/bash | |
sudo apt update | |
sudo apt install apache2 -y | |
sudo ufw allow 'Apache' | |
sudo systemctl start apache2 | |
sudo systemctl enable apache2 | |
echo "This is Server 1" >> /var/www/html/index.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment