Git Product home page Git Product logo

terraform-aws-ha-web-app's Introduction

terraform-aws-ha-web-app

Description

Builds a highly available AWS infrastructure from Terraform for a php web application communicating with a database.

infrastructure schema

More informations here

Modules

name usage
vpc Creates VPC with two public subnets for your ELB and two private subnets for your EC2 instances and your RDS service on different AZs
alb_asg Creates an Auto Scaling group with ELB of type "application"
cloudwatch_cpu_alarms Creates a cloudwatch alarms depending on the CPU usage and triggering ASG operations
s3 Creates an S3 bucket on which the sources of your application will be put
ec2_role_allow_s3 Creates an instance profile using an iam role authorizing access to S3 from your EC2 instances
rds Creates a mariadb relational database used for our EC2 web instances

How it works

To use this project, you must first indicate the root password of our database. In my case, I chose to define it in a file called terraform.tfvars (this file name is automatically considered by Terraform during the execution of your configuration). Example :

db_password = "your-password"

Second, you must then create your ssh key pair in the keys folder. In my case, I use the ssh-keygen command as follows :

ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/home/hatim/.ssh/id_rsa): ./keys/terraform
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 

Then add the path of your public key in your root module in the path_to_public_key parameter of the my_alb_asg module. In my case it will be :

module "my_alb_asg" {
    ...
    ...
    path_to_public_key   = "/home/hatim/Documents/tmp/terraform/sources/keys/terraform.pub"
    ...
    ...
}

You can then launch your configuration with the following command

terraform init && terraform apply

Result :

...
...

Outputs:

alb_dns_name = [DNS OF YOUR ELB] 

Finally open your browser and test your application from the dns name of your ELB :

result

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.