Complete the code to specify the Terraform state file name.
terraform {
backend "local" {
path = "[1]"
}
}The Terraform state file is usually named terraform.tfstate. It stores the current infrastructure state.
Complete the code to initialize the Terraform backend for remote state storage.
terraform {
backend "s3" {
bucket = "[1]"
key = "state/terraform.tfstate"
region = "us-east-1"
}
}The bucket specifies the S3 bucket name where the Terraform state file is stored remotely.
Fix the error in the Terraform state file reference.
output "instance_ip" { value = aws_instance.example.[1] }
ip_address or instance_ip.The correct attribute to get the public IP of an AWS instance in Terraform is public_ip.
Fill both blanks to define a Terraform state file backend with encryption enabled.
terraform {
backend "s3" {
bucket = "[1]"
encrypt = [2]
key = "prod/terraform.tfstate"
region = "us-west-2"
}
}encrypt to false when encryption is needed.The bucket is the S3 bucket name, and encrypt must be set to true to enable encryption of the state file.
Fill all three blanks to configure a remote backend with encryption and locking enabled.
terraform {
backend "s3" {
bucket = "[1]"
key = "envs/prod/terraform.tfstate"
region = "us-east-2"
dynamodb_table = "[2]"
encrypt = [3]
}
}The bucket is the S3 bucket name, dynamodb_table is used for state locking, and encrypt should be true to encrypt the state file at rest.