Complete the code to reference the environment variable for the Terraform variable 'region'.
variable "region" { type = string default = "us-west-1" } provider "aws" { region = var.[1] }
The Terraform variable is accessed using var.region. The environment variable TF_VAR_region sets this variable but is not used directly in code.
Complete the command to set the environment variable for Terraform variable 'instance_type' in Linux shell.
export [1]="t2.micro"
TF_VAR_ prefix.Terraform reads variables from environment variables prefixed with TF_VAR_. So to set instance_type, use TF_VAR_instance_type.
Fix the error in the Terraform variable declaration to use a default value from environment variable 'TF_VAR_bucket_name'.
variable "bucket_name" { type = string default = [1] }
TF_VAR_ prefix inside Terraform code.Terraform does not support using environment variables directly inside variable defaults. The default must be a literal or expression. Environment variables set TF_VAR_bucket_name externally.
Fill both blanks to correctly use a variable 'ami_id' set via environment variable and reference it in resource.
variable "ami_id" { type = string } resource "aws_instance" "example" { ami = var.[1] instance_type = "t2.micro" tags = { Name = "ExampleInstance" } lifecycle { ignore_changes = ["[2]"] } }
The variable is named ami_id and referenced as var.ami_id. The lifecycle block ignores changes to the ami_id attribute to prevent recreation.
Fill all three blanks to create a Terraform variable 'env' with default from environment variable, use it in provider, and output it.
variable "env" { type = string default = "[1]" } provider "aws" { region = var.[2] } output "environment" { value = var.[3] }
The variable env has a default value (e.g., "dev") which can be overridden by the environment variable TF_VAR_env. The provider uses var.env if it expects environment name, and the output shows var.env.