- An AWS account with access keys assigned to corresponding user.
- Basic understanding of the AWS console
- Visual Studio Code VSC (Windows)
- Enter Route 53 in search bar within AWS console.
- Select registered domains.
- Click on register domains.
- Search for desired domain availability and purchase it.
- Click on request certificate.
- Now enter your domain name from step 1.
- 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.
- Go to "list certificates" to confirm validation.
-
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.)
-
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"
- Copy the AMI i.d from AWS and paste this into line 3 of the "launchtemplate.tf" within VSC.
- 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.
- We will enter our keys into the VSC via the terminal
- In terminal enter:
aws configure
- 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.
- Now that we have VSC configured to AWS its time to initialize terraform. Run command:
terraform init
Notice our terraform init was successful
- Next we want to verify that our configuration is valid. Enter:
terraform validate
Notice this is also successful
- 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
- 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:
- 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
- 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.
- Next, on line 35 paste your subnet ids. Then save.
- Now, lets update our terraform. In our terminal we can enter:
terraform init -upgrade
Note: You will see this message
- Then, enter
terraform plan
Note: Resources to be added
- Now, enter
terraform apply -auto-approve
This will take awhile. I recommend a well deserved coffee break!
- Check your resources. Search EC2 in the AWS console and notice the DB instances.
- Now search for RDS and click on database.
Notice your DB
- 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!
- 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.
- Go to RDS. Click snapshots=>actions=>delete snapshot.
- Now in the same RDS section click on option groups.
- Select your option group and delete. [Do NOT touch the default]
⚠️
- On the next screen click delete.
You should see this message
Only the default option group should exist
- While we are in the console lets check if Terraform at least deleted our database. Yup its gone, this is good!
- 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