Complete the code to initialize Terraform state.
terraform [1]The terraform init command initializes the working directory and downloads necessary plugins, setting up the state file.
Complete the code to show the current Terraform state.
terraform [1]The terraform state list command lists all resources tracked in the current state file.
Fix the error in the backend configuration to enable remote state storage.
terraform {
backend "[1]" {
bucket = "my-terraform-state"
region = "us-west-2"
}
}The s3 backend stores Terraform state files in an AWS S3 bucket, enabling remote state management.
Fill both blanks to configure Terraform to lock state during operations.
terraform {
backend "s3" {
bucket = "my-terraform-state"
region = "us-west-2"
[1] = true
[2] = "dynamodb-table"
}
}Setting encrypt = true secures the state file, and dynamodb_table enables state locking using a DynamoDB table.
Fill all three blanks to output the current state file path and its format.
output "state_info" { value = { path = "[1]" format = "[2]" size = [3] } }
The default state file is terraform.tfstate, stored in JSON format. The size is an example number representing file size in bytes.