DevOps Classroomnotes 05/Jun/2022

Terraform backends

  • When two engineers execute the terraform configuration with a perspective to create infrastructure for an application, it creates two different infra.
    Preview
  • What if these two engineers want to create the same environment, in this case the state should not be on the local system, it should be present on common location.
  • This approach is called as backend. The default backend is local folder
    Preview
  • Refer Here for the terraform backends
    Preview
    Preview
  • Lets create a common infra for multiple users using Azure RM backend
    Refer Here for the changes done
  • For simulating multiple users i will be creating a linux instance, installing terraform and creating infra
  • Now execute initialization
    Preview
  • Now apply from system 2 and execute apply from system 1 as well, on system you should get an error message of lock acquired by some one else
    Preview
  • After successful apply from system 2 now execute apply from system 1
    Preview
  • AWS S3 Backend: We can use s3 backend, but for locking we need to use dynamo db. Refer Here
  • Refer Here for the s3 backend changeset
  • Initialize the backend and do the rest as done for azurerm backend
    Preview

Workspaces

  • Using Terraform configuration to create multiple environmetns from the same configuration
  • Refer Here for the changeset containing workspace demo features
  • Lets initialize
    Preview
  • Lets check for the workspaces available. create the dev on the system 2
    Preview
    Preview
  • Lets create dev from system 2 and qa from system 1 parallely
  • Dev from system 2
    Preview
    Preview

Lifecycle

Packer

  • Packer is a free and opensource tool to create images i.e we can create azure vm images, aws amis
  • Refer Here
  • Refer Here for installing packer
  • Refer Here for the example to create ami with packer in aws
  • Refer Here for the changes to create azure vm image

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner