Last active
May 24, 2021 02:28
-
-
Save reddysainathn/2b7acb084c79d2557b30528913d569fa to your computer and use it in GitHub Desktop.
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
| --- | |
| EC2 - Elastic Compute Cloud. | |
| --- | |
| Putty Download -- https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html | |
| ### Commands | |
| sudo su | |
| yum update -y | |
| yum install httpd | |
| systemctl start httpd | |
| systemctl enable httpd | |
| echo "Hello World" > /var/www/html/index.html | |
| 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 | |
| ---- COPY USER-DATA ---- | |
| #!/bin/bash | |
| yum update -y | |
| yum install -y httpd | |
| systemctl start httpd | |
| systemctl enable httpd | |
| curl -s http://169.254.169.254/latest/dynamic/instance-identity/document > /var/www/html/index.html | |
| -------- | |
| ----- CommandLine ----- | |
| - Start Instance by TagName. | |
| aws ec2 start-instances --instance-ids `aws ec2 describe-instances --filters "Name=tag:Name,Values=<--Name-->" --query 'Reservations[].Instances[].InstanceId' --output text` | |
| - Describe Instance by TagName. | |
| aws ec2 describe-instances --filters "Name=tag:Name,Values=EC2UsingUserData" --query 'Reservations[].Instances[].InstanceId' --output text | |
| < | |
| alias eTagStart="aws ec2 start-instances --instance-ids `aws ec2 describe-instances --filters "Name=tag:Name,Values=EC2UsingUserData" --query 'Reservations[].Instances[].InstanceId' --output text`" | |
| alias eTagStop="aws ec2 stop-instances --instance-ids `aws ec2 describe-instances --filters "Name=tag:Name,Values=EC2UsingUserData" --query 'Reservations[].Instances[].InstanceId' --output text`" | |
| > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment