Complete the code to specify the backend type for storing Terraform state remotely.
terraform {
backend "[1]" {}
}The s3 backend stores the Terraform state file securely in an AWS S3 bucket, which is a common practice for remote state management.
Complete the code to enable state locking using DynamoDB to prevent concurrent modifications.
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "state.tfstate"
region = "us-east-1"
dynamodb_table = "[1]"
}
}The dynamodb_table attribute specifies the DynamoDB table used for state locking. 'terraform-locks' is a common table name for this purpose.
Fix the error in the backend configuration to encrypt the state file at rest.
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "state.tfstate"
region = "us-east-1"
encrypt = [1]
}
}The encrypt attribute expects a boolean value true without quotes to enable encryption of the state file at rest.
Fill both blanks to configure remote state with S3 backend and enable encryption for state file safety.
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "state.tfstate"
region = "us-east-1"
[1] = true
[2] = "arn:aws:kms:us-east-1:123456789012:key/abcd-1234"
}
}The encrypt attribute enables encryption of the state file, and kms_key_id specifies the AWS KMS key ARN used for encryption.
Fill all three blanks to define a secure backend with S3 bucket, DynamoDB locking, and encryption enabled.
terraform {
backend "s3" {
bucket = "[1]"
key = "terraform.tfstate"
region = "us-west-2"
dynamodb_table = "[2]"
encrypt = [3]
}
}The bucket is the S3 bucket name, dynamodb_table is the table used for locking, and encrypt set to true enables encryption of the state file.