Scenario – 1: Ntier application infra – AWS
-
N tier application
-
AWS
-
Concepts:
- AZ
- CIDR
-
Ips reserved for private usage
- 10.0.0.0 to 10.255.255.255
- 172.16.0.0 to 172.31.255.255
- 192.168.0.0 to 192.168.255.255
- Manual Creation: Watch classroom recording
Working with terraform
- Where are we creating these resources (Provider) => aws
- account =>
<your account>
- account =>
- What are we creating (resources)
- vpc
- cidr: 192.168.0.0/16
- Tag:
- Key: Name
- Value: from-tf
- subnets
- web
- Tag:
- Key: Name
- Value: web
- CIDR: 192.168.0.0/24
- AZ: ap-south-1a
- Tag:
- app
- Tag:
- Key: Name
- Value: app
- CIDR: 192.168.1.0/24
- AZ: ap-south-1a
- Tag:
- db
- Tag:
- Key: Name
- Value: db
- CIDR: 192.168.2.0/24
- AZ: ap-south-1a
- Tag:
- web
- internet-gateway
- route table:
- private:
- Tag:
- Key: Name
- Value: private
- subnet associations:
- app
- db
- Tag:
- public
- Tag:
- Key: Name
- Value: public
- Route:
- 0.0.0.0/0 -> igw
- subnet associations:
- web
- Tag:
- private:
- Order of creation:
- vpc
- subnets
- igw
- routetables
- vpc
Configuring aws credentials with terraform
- For this we use aws cli and create a IAM user for terraform (Watch classroom recording)
working with Terrraform
- Create a new folder
aws-ntier - open this folder in vscode
- create a file called as
providers.tfin which we configure terraform block and providers
HCL (Haschicorp configuration language)
-
Block: generally blocks will be enclosed in
{ }- We have providers block, resources block, datasource block, outputs block, terraform block
- syntax
<block-type> {
arg1 = value1
..
argn = valuen
}
- Providers block
provider "<PROVIDER_NAME>" {
<PROVIDER_ARGUMENTS>
alias = "<ALIAS_NAME>"
}
- AWS Provider reference and argument reference
-
Provider in Terraform gives
- Resources
- Data sources
- In providers.tf write
provider "aws" {
region = "ap-south-1"
}
- Once the providers is definied execute
terraform init
