# Chapter -2

This chapter covers,

```
Creating a blogging infrastructure
Analyzing costs of a blogging infrastructure
Exploring a blogging infrastructure
Shutting down a blogging infrastructure
```

### Simple Project :&#x20;

&#x20;         Background :&#x20;

&#x20;             \>>  Imagine you work for a mid-sized company that runs a blog to attract new software and operations engineers. Wordpress is used as a content management system and Around 1,000 people visit the blog daily. You are paying $150 USD per month for the\
on-premises infrastructure. This seems expensive to you, particularly because at the\
moment the blog is suffering from several outages per month.

&#x20;        \>> So, you are evaluating new options to operate wordpress reliably. AWS Seems to be a good fit. As a proof of concept, you want to evaluate whether a migration is possible. To do so you need to do the following :&#x20;

* setup a highly available infrastructure for wordpress
* Estimate monthly costs of Infrastructure
* Come to a decesion and delete the infrastructure afterwards

Wordpress is written in PHP and uses a MYSQL database to store data. Apache is used as a web server to serve the pages.&#x20;

### creating Infrastructure :&#x20;

&#x20;          Below are the five different AWS services to copy old infrastructure to AWS :&#x20;

1. **Elastic Load Balancer (ELB)** :  AWS offers loadbalancer as a service. The loadbalancer distributes traffic to a bunch of virtual machines, and is highly available by default. Requests are routed to virtual machines as long as their health check succeeds. you'll use the Application load balancer which operates on Layer 7 (HTTP and HTTPS)
2. **Elastic Compute Cloud (EC2)** : EC2 service provides virtual machines. you'll use a linux machine with an optimized distribution called Amazon Linux to install Apache, PHP and wordpress. you could also choose any other os/distribution also like ubuntu, redhat, windows etc. Virtual machines may fail, so you need atleast two of them. The loadbalancer will distribute the traffic between them. In case virtual machine failed loadbalancer will stop traffic for it and divert to another Vm and it has to handle traffic till failed Vm replaced.
3. **Relational Database (RDS) for MySQL** :  Wordpress relies on popular mysql database, AWS provides MYSQL with its RDS. you choose the database size (storage, CPU, RAM) and RDS takes over operating tasks like creating backups and installing patches and updates. RDS can also provide a highly available MYSQL database by replication
4. **Elastic File System (EFS)** :  Wordpress itself consists of a PHP and other application files. user uploads, for example images added to an article, are stored as files as well. By using a network file system, your virtual machines can access these files. EFS provides a scalable, highly available and durable network file system using NFSv4.1 protocol
5. **Security Groups** :  Controlling incoming and outgoing traffic to your virtual machine, your database or your load balancer with a firewall. For example, use a security group allowing incoming HTTP traffic from the internet to port 80 of the load balancer. or restrict network access to your database on port 3306 to the virtual machines running your web browsers.

<figure><img src="/files/qTH7M2LOSjFYGeQl9USA" alt=""><figcaption></figcaption></figure>

1. Create a load balancer (ELB).
2. &#x20;Create a MySQL database (RDS).
3. Create a network filesystem (EFS).
4. &#x20;Create and attach firewall rules (security groups).
5. Create two virtual machines running web servers:   \
   a Create two virtual machines (EC2).   \
   b Mount the network filesystem.   \
   c Install Apache and PHP.   \
   d Download and extract the 4.8 release of WordPress.   \
   e Configure WordPress to use the created MySQL database (RDS).   \
   f Start the Apache web server

To create the infrastructure for your proof-of-concept, open the AWS Management\
Console at `https://console.aws.amazon.com`&#x20;

on top you will find search bar click on it and search for cloudformation then click on new stack. [https://s3.amazonaws.com/\
awsinaction-code2/chapter02/template.yaml](<https://s3.amazonaws.com/&#xD;&#xA;awsinaction-code2/chapter02/template.yaml>) give this stack as value .&#x20;

<figure><img src="/files/DVq19cu93dKtXKMLCidO" alt=""><figcaption></figcaption></figure>

then click next and give any key values of your choice. I have given system as key and value as wordpress and click next on the bottom left of the page. Finally click on save.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://charan-techjourney.gitbook.io/charan-techjournal/books/amazon-web-services-in-action/chapter-2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
