Complete the code to initialize the Terraform backend.
terraform [1]The terraform init command initializes the backend and prepares the working directory.
Complete the code to migrate the Terraform state to a new backend.
terraform [1] -migrate-stateThe terraform init -migrate-state command migrates the state to the new backend configuration.
Fix the error in the backend configuration block by completing the missing backend type.
terraform {
backend "[1]" {
bucket = "my-terraform-state"
region = "us-west-2"
}
}The backend type s3 is used for storing Terraform state in an AWS S3 bucket.
Fill both blanks to configure a remote backend with encryption and versioning enabled.
terraform {
backend "s3" {
bucket = "my-terraform-state"
region = "us-east-1"
[1] = true
[2] = true
}
}The encrypt option enables encryption of the state file, and versioning enables versioning on the S3 bucket.
Fill all three blanks to write a backend block for Azure Blob Storage with container and key specified.
terraform {
backend "[1]" {
storage_account_name = "mystorageaccount"
container_name = "[2]"
key = "[3]"
}
}The backend type for Azure Blob Storage is azurerm. The container_name is typically a container like tfstate, and the key is the state file name, commonly terraform.tfstate.