Published 3月 12, 2019 by with 0 comment

Amazon EC2 - Labs - 01 - Lauch An EC2 Instance


AWS > Compute > Amazon Elastic Compute Cloud (EC2):

Lab Summary
1. Termination protection is turned off by default, you must turn it on.
2. On an EBS-backed instance, the default action is for the root EBS voiume to be deleted when the instance is terminated.
3. EBS Root Volumes of your DEFAULT AMI's CANNOT be encrypted. you can also use a third party tool (such as bit locker etc) to encrypt the root volume, or this can be done when creating AMI's in the AWS console or using the API.
4. Additional volumes can be encrypted.

Lab Configuration
1. Login to EC2 From Linux
$ssh ec2-user@52.56.97.82 -i MyEC2KeyPair.pem

2. Change to Root
[ec2-user@ip-172.31.9.182 ~]$ sudo su

3. Update to application version
[root@ip-172-31-9-185 ec2-user]# yum update -y

4. Install Apache
[root@ip-172-31-9-185 ec2-user]# yum install httpd -y

5. create a index.html
[root@ip-172-31-9-185 ec2-user]# cd /var/www/html
[root@ip-172-31-9-185 html]# vi index.html
### Remove * ###
<*html><*h1>Hello World!<*/h1><*/html>

6. Restart the HTTP service
[root@ip-172-31-9-185 html]# service httpd restart

7. Make sure the Apache service always start everytime when reboot EC2.
[root@ip-172-31-9-185 html]# chkconfig http on

8. After create a new user in the IAM, you can configure credentials.
[root@ip-172-31-9-185 html]# aws configure
AWS Access Key ID [None]: Get it from the new user's csv file.
AWS Secret Access Key [None]: Get it from the new user's csv file.
Default region name [None]: Get it from google "AWS region"
Default optput format [None]:

9. List S3 resource
[root@ip-172-31-9-185 html]# aws s3 ls

10. List S3 commands help
[root@ip-172-31-9-185 html]# aws s3 help

11. The location of the credential file
[root@ip-172-31-9-185 html]# cd ~
[root@ip-172-31-9-185 ~]# cd .aws
[root@ip-172-31-9-185 .aws]# ls
config credentials

12. Get EC2 ID
[root@ip-172-31-9-185 .aws]# aws ec2 describe-instances

13. Using CLI to terminate EC2 instance
[root@ip-172-31-9-185 .aws]# aws ec2 terminate-instances --instance-ids i-03f025db77a5d4747


Reference:
1. AWS Documentation - AWS CLI Command Reference - EC2
https://docs.aws.amazon.com/cli/latest/reference/ec2/index.html

2. Udemy - AWS Solutions Architect - Associate::
https://www.udemy.com/aws-certified-solutions-architect-associate/


最初發表 / 最後更新: 2019.03.15 / 2020.06.08

0 comments:

張貼留言