Implement 2-tier architecture in AWS using Terraform

Always learning
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.

  1. Create a directory under which we will be writing all our configuration files.
  2. 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”
}

Creation of backend and State locking

--

--

Always learning
Always learning

Written by Always learning

கற்றுக் கொள்ளும் மாணவன்...

No responses yet