Table of contents
No headings in the article.
A backend in Terraform lets us know where the Terraform state files are going to be stored. Terraform stores information about your infrastructure in a state file. This state file keeps track of resources created by your configuration and maps them to real-world resources.
The Terraform backend can be:
1.Local - This works fine when we use it to learn Terraform and the state is stored on the local disk but in real world team environments this is not a compatible option.
2.Remote - The state file is stored in some remote filesystem or database. In general using s3 to store remote state and dynamo db database for state locking. Terraform will lock your state for all operations that could write state. This prevents others from acquiring the lock and potentially corrupting your state. State locking happens automatically on all operations that could write state.
This option works well in a team environment where team members are working on using Terraform - Infrastructure as Code to provision resources.
The remote backend when using s3 for example can be defined as follows:
terraform {
backend "s3" {
bucket = "s3-bucket-name"
key = "s3folder-to-store-state/state-file-name"
region = "aws-region"
dynamodb_table = "dynamo-db-tablename"
}
}
Author : Chandrasekar(Chan) Rajaram
https://www.linkedin.com/in/chan-rajaram-software-engineer/
#devops