Final - max-gallagher/SYS-360 GitHub Wiki

Final Project

Part 1

Configuration Steps

Configure Networking

VPC

  • Create a new VPC (for subnet range I did 10.10.0.0/16)

image

image

Subnets

  • Public Subnet

image

  • Private Subnet

image

  • Ensure that everything was created properly

image

Internet Gateways

  • Create Gateway

image

  • Attach it to the VPC

image

image

Route Tables

  • Create both public and private route tables

image image

  • Associate the subnets with their respective tables

image

image

image

  • Config public table to allow for internet traffic (make sure to select the internet gateway we made earlier)

image

Elastic IPs

  • Create 2 Elastic IPs

image

  • Once EC2 instances are made allocate them to the 2 on the public subnet

image

Create Instances

  • Go to EC2 Console

  • Go to instances then create instance

Linux-Apache-PHP (Public Subnet 10.10.10.25)

image

image

image

Jumpbox (Public Subnet 10.10.10.30)

image

image

MySQL (Private 10.10.15.60)

image

image

image

Results

image

Configure Security Groups

  • Public Security Group

image

  • Private Security Group

image

NAT-Gateway

  • Go back to VPC

  • Go to NAT Gateways and create a new gateway on the Public Subnet

image

image

Test Connectivity

  • SSH into web

image

  • SSH into jumpbox

image

  • SSH into MySQL from jumpbox

image

EC2 Web and MySQL as a LAMP Stack

MySQL installation

  • On MySQL box run
apt-get update
apt-get install mysql-server

image

  • Ensure it is running

image

  • Setup MySQL/Wordpress

Source: https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-centos-7

  • Login to mysql with:
mysql -u root -p
  • Start setting up wordpress by creating the database and a new privileged user for it
CREATE DATABASE wordpress;
CREATE USER [email protected] IDENTIFIED BY 'insert password here';
GRANT ALL PRIVILEGES ON wordpress.* TO [email protected];
FLUSH PRIVILEGES;
  • Move over to the Web box and install wordpress

(pre-requisites)

sudo apt-get update
sudo apt-get install apache2
sudo apt-get install php
sudo apt-get install php-gd
sudo apt-get install php-mysqlnd
sudo apt-get install mariadb-client
sudo systemctl enable apache2
sudo systemctl start apache2

(wordpress install)

wget http://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
sudo rsync -avP ~/wordpress/ /var/www/html/
sudo mkdir /var/www/html/wp-content/uploads
sudo chown -R www-data:www-data /var/www/html/*
cd /var/www/html
cp wp-config-sample.php wp-config.php
  • You now need to edit wp-config.php to contain your MySql/Wordpress credentials

  • Once that has been done restart apache and you should be all set

image

image

image

Part 2

Configure CloudWatch for Instance Monitoring

  • Turn on detailed monitoring for Web and MySQL instances and basic monitoring for the jump box
    • to turn on detailed monitoring click the check box next to the desired ec2 instance then go to actions -> monitor and troubleshoot -> manage detailed monitoring and then click enable.

image

Configure CloudWatch for Instance Metrics:

  • Go to the cloudwatch dashboard and click on the all metrics tab on the left of the screen

  • Find 3 metrics you want to set alarms for, I chose EC2 CPU Utilization, NAT Gateway PacketsDropCount, and EC2 StatusCheckFailed

  • Once you have found the metrics you want to monitor click on it and you should be brought to a screen like shown below

image

  • Click the bell icon next to the instances you want to set the alarm for in order to create the alarm

    • For cpu utilization i made the threshold 80% usage

image

image

  • Now do this for all 3 metrics

image

Configure CloudTrail for AWS auditing

  • Head over to the cloudtrail dashboard

  • Create a new trail (CTFinal)

  • Create a new S3 Bucket in this case I just kept the default name

  • Disable SSE-KMS encryption

  • Add 1 key + value combo in tags, in this case I just made the key Final and the value Cloudtrail

image

  • Click next and enable insight events

image

  • Leave everything else as default and create the trail

  • After some time cloudtrail logs should begin to populate in the s3 bucket

image

  • Here is an example of one of the cloudtrail logs, this log entry specifically represent API calls made from my AWS environment, containing details such as the event source, event name, user identity and, request parameters.

image