
Hello Readers, In this blog we’ll see that how we can set-up OR create networks in AWS using Terraform. Before starting you must have Terraform, AWS CLI install on your local machine and they both must be configure.
It is easy to set-up Networks using terraform. In order to do so you should follow certain steps. These are as follows:
- Go the terraform docs and copy the content from the terraform docs of aws_vpc, aws_subnets, aws_route_table.
- Open your terminal and make one directory and and under that dir make file named as networks.tf , and paste the content that you have copied from the url.
Run the following commands to do so :
cd Documents mkdir Terraform mkdir aws nano networks.tf



- Check your file by :
cat networks.tf



- Remember you should have aws CLI in your local machine and then Configure your AWS by running the command:
aws configure
- Make one more file named as provider.tf to give your credentials for AWS as:
provider "aws"{
region = "us-east-1"
access_key = "Your_Access_Key"
secret_key = "Your_Secret_Key"
}
- Now you can run the command in your terminal as given below:
terraform init



- Now let’s plan it . Plan is basically you are creating anything and what exactly you will get as the result when you run the given command.
terraform plan






- finally run the command given below to apply it. You will see your netwroks are creating after providing it the value as ‘Yes’.
terraform apply






- Login into your AWS Console and search for service as VPC, you will see that your vpc, subnets, internet gateway and route table is created.
So now we have successfully created our networks using terraform in AWS.
Conclusion
So, In this blog we have seen in some simple steps how we can create and setup vpc, subnets, internet gateway and route table in AWS using terraform.Thanks for being with me till the end. If you find this blog helpful do share with your friends.
Reference


