AWS Classroom Series – 27/Apr/2021

Deploying a sample application to ec2

  • Create an ubuntu ec2 instance
  • Install lamp stack in it Refer Here
  • Steps:
#!/bin/bash
sudo apt update
sudo apt install apache2 -y
sudo apt install php libapache2-mod-php php-mysql -y
sudo apt install php-cli -y
echo "<?php phpinfo(); ?>" | sudo tee -a /var/www/html/info.php
sudo apt install stress -y

Preview

  • Now lets try to achieve the same using userdata
#!/bin/bash
sudo apt update
sudo apt install apache2 -y
sudo apt install php libapache2-mod-php php-mysql -y
sudo apt install php-cli -y
echo "<?php phpinfo(); ?>" | sudo tee -a /var/www/html/info.php
sudo apt install stress -y
  • Steps Preview Preview Preview Preview Preview
  • Now consider we need lamp stack on 10 vms
    • We can set the user data for all the 10 vms, but here the problem is the script executes on 10 vms and we have to wait till the application is installed completely
  • Now lets try to create an AMI from the existing lampstack Preview Preview Preview Preview Preview Preview
  • Now create an ec2 instance with your ami Preview Preview Preview
  • To configure an app in ec2
    • approach 1: create a linux/windows instance & install manually
    • approach 2: Execute the script to install/configure the application using userdata
    • approach 3: Create a resuable AMI and launch AMI to create instance of your application

Leave a Reply

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

About learningthoughtsadmin