Implement 2-tier architecture in AWS using Terraform
6 min readJun 27, 2023
Prerequisites
- AWS account Accesskey and Secret key.
- AWS CLI and Terraform Installed in your system
- Any IDE i.e) VS code or Pycharm.
Creating providers and variables configuration files.
- Create a directory under which we will be writing all our configuration files.
- Create a provider.tf file inside that directory.
provider “aws” {
region = var.region
access_key = “A****************”
secret_key = “cxz***************`”
}
Create a variable.tf file to declare all the variables that are required.
variable “region” {
default = “ap-south-1”
}
variable “vpc_cidr” {
default = “172.33.0.0/16”
}variable “subnets” {
type = list(string)
default = [“webtier-public-subnet1”,”webtier-public-subnet2",”dbtier-private-subnet1",”dbtier-private-subnet2"]
}variable “ec2_ami” {
description = “AMI to Launch Instance”
default = “ami-0607784b46cbe5816”
}variable “instance_type” {
default = “t2.micro”
}