DevOps Classroomnotes 29/Mar/2023

Multi user

  • Lets create a simple terraform template to create vpc Refer Here for the changes
  • Execute this from two different machines.
  • Consider both of them are working for same purpose
  • User 1:
  • User 2:
  • Execution Create two different resources, which is not desired
  • As of now state is stored locally i.e. when user1 executes it is stored in user1 system and same for user2
  • To solve this problem we need to store the state in some common place
  • The location of state file in terraform is defined by backend.

Terraform Backends

  • Backend defines where the state has to be stored
  • Refer Here for offical docs and Refer Here for configuring backend
  • There are two types of backends
    • local-backend:
      • This is default backend
    • remote-backend
  • Refer Here for available backends
  • As common state for terraform for multiple users will have concurrency problem, Terraform backends need locking and unlocking
  • S3 bucket can be used as terraform backend, S3 buckend doesnot support locking, if you need locking add dynamo db details

Remote Backends with S3

  • Refer Here for official docs
  • Create an s3 bucket
  • Create a dynamo DB table with any name and partition key LockID
  • Refer Here for the changes done to add s3 backend
  • Perform init on both user machines
  • Now lets user1 apply the changes
  • Now while user1 is still applying let user 2 also apply
  • Let user1 finish applying and create the resources
  • Now let user2 try applying

  • Exercise: Configure Azurerm backend Refer Here which has inbuilt locking facility

Next Steps

  • Provisioning
  • Immutable Infrastructure
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

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

Please turn AdBlock off
Customized Social Media Icons from Acurax Digital Marketing Agency
Exit mobile version
%%footer%%