DevOps Classroomnotes 01/Apr/2023

Solving Problem with count using for each

Immutable Infrastructure

  • when there is any change needed to be done in infra change template not infra.
  • Every change needs to be version controlled.


  • Refer Here for provisioners
  • Terraform recommends using cloud-init custom data or user-date instead of provisioners if possible Refer Here
  • Refer Here for the chagnes
  • Refer Here for the changes done in azure to create vm with custom_data

Terraform provisioners

  • Terraform has two kinds of provisioners
    • local-exec: This executes on the machine where terraform apply is executed
    • remote-exec: This executes on the remote machine generally the machine created
    • file provisioner: which is used to copy file from local to remote
    • For remote provisoners and file provisoners copying into remote we need connections to be managed Refer Here
  • we can specify when to do provisioning
    • during create
    • during destroy
  • Refer Here for provisioner in azure
  • Refer Here for the changes done to perform provisioning in aws
  • Terraform taint is used to mark a resource for recreation during next apply
  • When we want to change the script every time to make it work, we should be taiting terraform taint <resourcetype>.<resourcename>
  • To solve this problem we use null_resource Refer Here
  • Refer Here for the usage of null resource in terraform aws example and Refer Here for changes in terraform azure example

Building Reusable templates in Terraform using Modules

  • Refer Here for the template which can create vpc with public and private subnets
  • Now we want to make that reusable.
  • To do that we need to create modules Refer Here
  • Terraform modules has
    • inputs
    • resources
    • outputs
  • Group them and this becomes module
  • Refer Here for module demo
  • Terraform registry hosts lot of community modules Refer Here
  • Refer Here for sample aws vpc communityt module
  • Possible module sources Refer Here

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner