Member-only story
Check my YouTube video for this article
https://www.youtube.com/watch?v=MLDFcN3IhB0
For more articles, please follow my website
In this blog, we will learn How to manage terraform state file remotely on S3 bucket. By default, our terraform state file is stored locally. Now we will explore to store it in S3 bucket
If you are working on a team, then its best to store the terraform state file remotely so that many people can access it
If the state file is stored remotely so that many people can access it, then you risk multiple people attempting to make changes to the same file at the exact same time. So we need to provide a mechanism that will “lock” the state if its currently in-use by another user. We can accomplish this by creating a dynamoDB table for terraform to use.
So you need 3 things
- s3 bucket to store the state file in
2. Terraform s3 backend resource.
3. DynamoDB
Example to create S3 bucket and Dynamodb table
Clone this git repo
provider "aws" {
region = var.region
}# terraform state file setup
# create an S3 bucket for vpc to store the state file inresource "aws_s3_bucket" "terraform-state-storage-s3-devops4solutions" {
bucket =…