AWS Classroomnotes 13/Sep/2022

AWS EC2 contd…

Activity 3

  • Create an ec2 instance with
    • ubuntu 20.04 AMI
    • imported key pair
    • 22 and 80 port open to all
    • instance type: t2.micro
  • Install webserver => Apache with php
sudo apt update
sudo apt install apache2 stress -y
sudo apt install php libapache2-mod-php php-mysql -y
echo '<?php phpinfo(); ?>' > info.php
sudo cp info.php /var/www/html/info.php
  • Solution 1: Create ec2 instance with above options. SSH into EC2 and execute the commands
    • SSH and execute the following commands
      Preview
    • Now navigate to http://<publicip>/info.php
      Preview
  • Solution 2: User Data
    • Open Advanced details while creating ec2 instance and navigate to the user data section
      Preview
    • Now launch ec2 instance
    • Now navigate to http://<publicip>/info.php
      Preview
    • Userdata is the script that will be executed as a root user by your aws instance.
    • This script gets execute only while creating the ec2 instance.
    • Lets verify the logs
      Preview
  • Refer Here for cloud-init.

AWS EC2 instance Lifecycle

  • The billing part of the ec2 instance will be applicable only for on-demand instances.
  • Refer the below image for instance states
    Preview
  • Refer Here for the offical docs on instance lifecycle.
  • Actions that can be performed on ec2
    • launch => Create an ec2 instance
    • stop => stop the ec2 instance which is running
    • start => start the ec2 instance which is stopped
    • terminate => terminate the running or stopped ec2 instance
    • stop-hibernate => hibernate the ec2 instance which is running

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Wordpress Development Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube