Luis Miguel Guerra Quispe
Posted on October 19, 2022
Install Terraform and create a custom VPC
I am learning to create Infrastructure with Terraform from scratch, I decided to apply what I learned and be able to share it with you.
Any comments on how to improve these instructions let me know.
I hope you find this helpful
The instructions below are for Windows .
- Install VSCode from https://code.visualstudio.com/
- Install Terraform from https://chocolatey.org/install
- Install GIT from https://git-scm.com/downloads
- Install AWS CLI from https://awscli.amazonaws.com/AWSCLIV2.msi
We will proceed to configure our AWS Credentials with CLI.
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html
After having the necessary tools, we will proceed to clone the repository.
https://github.com/lguerraq/AWS-VPC
We will open the cloned folder with VSCode.
We will place the name of the configured profile in the Credentials file (/.aws/credentials)
variable "profile" {
description = "Profile for providers"
type = string
default = "NameProfile"
}
With the aforementioned we will proceed to apply the Terraform commands for the deployment.
### Init terraform
* terraform init
### Validate terraform
* terraform validate
### Fmt terraform
* terraform fmt
### Plan terraform by environment
* terraform plan -var-file environment-vars/prd.tfvars
### Apply terraform by environment
* terraform apply -var-file environment-vars/prd.tfvars
### Destroy terraform by environment
* terraform destroy -var-file environment-vars/prd.tfvars
https://www.terraform.io/cli/commands
Until the execution of Terraform apply we will validate that our VPC was created correctly.
To destroy the VPC we will execute Terraform destroy.
Posted on October 19, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 17, 2024