Giter Club home page Giter Club logo

multi-tier's Introduction

Creating Three Tier Architecture

Prerequisites

  • An AWS account with access keys assigned to corresponding user.
  • Basic understanding of the AWS console
  • Visual Studio Code VSC (Windows)

Step 1: Go to Route 53

  1. Enter Route 53 in search bar within AWS console.
  2. Select registered domains.

image description

  1. Click on register domains.

image description

  1. Search for desired domain availability and purchase it.

image description

Step 2: Go to AWS Certificate Manager

  1. Click on request certificate.

image description

  1. Now enter your domain name from step 1.
  2. And choose certificate validatation via. Email (Though DNS validation is recommended I choose the email option being that it is faster).

Note: Validation can take up to an hour.

  1. Go to "list certificates" to confirm validation.

Step 3 Open Visual Studio Code and import .tf files 0-11 from "Multi-Tier" repo

  1. For now we need all .tf files except 12-RDSDB.tf. Once files are open in VSC modify them as necessary. (Instructions are included within code.)

  2. Type EC2 in the search bar of the AWS console, and click launch instance.

    Note: we are not actually launching an instance we just need some variables from the console to enter into our "launchtemplate.tf"

  1. Copy the AMI i.d from AWS and paste this into line 3 of the "launchtemplate.tf" within VSC.

  1. Go back to console and on the same instance set-up page scroll down and click "create new key pair" name it and download it to your local machine. This key will help us to connect to AWS through VSC, alongside the AWS access keys that are attached to your user which you should already have. More on access keys next.

Step 4 Input your Access keys into VSC

  1. We will enter our keys into the VSC via the terminal
  2. In terminal enter:
aws configure
  1. You want to enter your AWS access keys and secrets access keys in the provided locations, as well as your desired region and output format which in this case is json. Now press enter one more time to take you back to the present working directory.

Step 5 Run Terraform script

  1. Now that we have VSC configured to AWS its time to initialize terraform. Run command:
terraform init

Notice our terraform init was successful

  1. Next we want to verify that our configuration is valid. Enter:
terraform validate

Notice this is also successful

  1. Now, we will plan to deploy our resources in AWS with this command:
terraform plan

Note: you may be prompted to enter your region of choice after entering this command otherwise you will get a count of the resources that you plan to deploy

  1. Next, we will apply our resources with this command:
terraform apply

You will be asked to approve this action, so enter "yes". However if you want to skip this step, instead of entering the above command you can enter:

terraform apply -auto-approve

Once your deployment is complete you will get this message:

  1. Now, go to the AWS console to ensure that your resources have been populated. Enter EC2 in the search bar, and then enter VPC to check for resources

Step 6 Add RDS DB

  1. Remember we deployed modules 0-11, but not 12. We did this because in order to deploy the DB we will need the subnet i.d. (in this case we need three). The subnet ids. are provided in our terminal after the initial deployment. We only want private subnets to house our DB.

2.Import the 12-RDSDB.tf into VSC and save. 3.Then enter:

aws rds describe-db-engine-versions --engine mysql --query "DBEngineVersions[].EngineVersion"

*Note we need to ensure that our DB has one of the following versions in order to ensure we do not get any errors. If version is not current modify this section now. SEE line 7 of 12-RDSDB.tf module.

  1. Next, on line 35 paste your subnet ids. Then save.
  2. Now, lets update our terraform. In our terminal we can enter:
terraform init -upgrade

Note: You will see this message

  1. Then, enter
terraform plan

Note: Resources to be added

  1. Now, enter
terraform apply -auto-approve

This will take awhile. I recommend a well deserved coffee break!

Welcome Back! Your DB has been deployed

  1. Check your resources. Search EC2 in the AWS console and notice the DB instances.

  1. Now search for RDS and click on database.

Notice your DB

Step 7 Tear down

  1. Time to clean up. Lets run this command:
terraform destroy

Note you can also run the following command as well in order to avoid terraform from questioning your action.

terraform destroy -auto-approve

Again, this will take awhile. Coffee, workout, study, or popcorn. Whatever floats your boat!

Uh-oh looks like we have an error ๐Ÿ˜ฎ

  • No worries. The RDS option group is used by final DB snapshot. Terraform doesn't know about this. The option group can be removed only when final snapshot is removed.
  • To do this we must go to the AWS console and delete the snapshot first.

Step 8 Goodbye Option Group ๐Ÿ‘‹

  1. Go to RDS. Click snapshots=>actions=>delete snapshot.

  1. Now in the same RDS section click on option groups.

  1. Select your option group and delete. [Do NOT touch the default] โš ๏ธ

  1. On the next screen click delete.

You should see this message

Only the default option group should exist

  1. While we are in the console lets check if Terraform at least deleted our database. Yup its gone, this is good!

  1. Lastly lets go back to VSC and run this command one more time to verify that all resources have been terminated.
terraform destroy -auto-approve

Congratulations! ๐Ÿ˜Ž Not a resource in site! ๐Ÿ‘

multi-tier's People

Contributors

archandrew avatar

Watchers

 avatar

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.