Complete the code to specify the backend type for remote state storage.
terraform {
backend "[1]" {}
}The s3 backend stores Terraform state remotely in an AWS S3 bucket, which is suitable for team collaboration.
Complete the code to specify the S3 bucket name for remote state.
terraform {
backend "s3" {
bucket = "[1]"
}
}The bucket name my-terraform-state is an example of a remote S3 bucket used to store Terraform state for teams.
Fix the error in the backend configuration to enable state locking with DynamoDB.
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "global/s3/terraform.tfstate"
region = "us-west-2"
[1] = "terraform-lock"
}
}The correct attribute to enable state locking with DynamoDB is dynamodb_table.
Fill both blanks to configure remote state with S3 backend and enable encryption.
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "prod/terraform.tfstate"
region = "us-east-1"
[1] = true
[2] = true
}
}The encrypt option enables server-side encryption for the state file, and versioning helps keep multiple versions of the state for safety.
Fill all three blanks to configure remote state with S3 backend, DynamoDB locking, and specify the state file path.
terraform {
backend "s3" {
bucket = "[1]"
key = "[2]"
dynamodb_table = "[3]"
region = "us-east-2"
}
}The bucket name is team-terraform-state, the key is the path env/prod/terraform.tfstate, and the DynamoDB table for locking is terraform-lock-table.