DevOps Classroom Series – 12/Oct/2020

Terraform Contd..

  • Lets try to create a ntier archtiecture for aws
  • The below image demonstrates the architecture to be realized in aws Preview
  • Now lets just focus on network and make the changes Refer Here
  • Now execute the following commands
terraform plan --help
terraform plan -out 'ntier.plan' .

Preview Preview Preview

  • Terraform creates a plan file with the desired state details, so lets execute
terraform apply ntier.plan

Preview

  • When the terraform has executed a new file called terraform.tfstate is created. This statefile is representation of what has been provisioned by terraform.
  • Terraform state files by default are stored in the local machine (local folder where tf files are available), SO if two users from different systems try to execute terraform apply, it results in two different infrastructures created. Preview
  • But if you want two system to create same infrastructure, then terraform supports remote backends Refer Here Preview
  • So we need to implement backends. (This will be done in next class)
  • If we want to create 4 subnets, we are writing the resource 4 times. It will be better if we have some thing like
for (index=0; index<4;index++ ) {
    resource "aws_subnet" "subnet" {

    }
}
  • Refer Here and check for for expressions

  • Lets use this loop for creating 4 subnets Refer Here

  • Exercise: Try to use loops to create 4 subnets in Azure.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin