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
  • 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' .

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

  • 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.
  • But if you want two system to create same infrastructure, then terraform supports remote backends Refer Here
  • 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 ReplyCancel reply

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

Please turn AdBlock off
Social Network Integration by Acurax Social Media Branding Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%