Skip to content

ArchAndrew/Multi-tier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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! 👏

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages