TF-003 Understand Terraform basics • Complete Question Bank
Complete TF-003 Understand Terraform basics question bank — all 0 questions with answers and detailed explanations.
Refer to the exhibit.
```hcl
resource "aws_instance" "web" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
tags = {
Name = "WebServer"
}
}
resource "aws_eip" "ip" {
instance = aws_instance.web.id
}
```You are a platform engineer at a fintech company. Your team manages a multi-region application on AWS using Terraform. The infrastructure includes VPCs, subnets, EC2 instances, and an Application Load Balancer (ALB). The configuration uses modules from the Terraform Registry and remote state in S3 with DynamoDB locking.
Recently, after a colleague ran `terraform apply` in the us-east-1 region, the application experienced downtime because the ALB's target group was accidentally updated to point to instances in us-west-2 instead of us-east-1. The root cause was that the Terraform configuration for the ALB used a variable `target_region` which was hardcoded to us-west-2 in a `terraform.tfvars` file that was not intended for that workspace.
Your team wants to prevent such misconfigurations in the future. Which course of action would most effectively reduce the risk of using incorrect variable values across workspaces?
Drag steps to the numbered slots on the right, or tap a step then tap a slot.
Drag steps to the numbered slots on the right, or tap a step then tap a slot.
Drag a concept onto its matching description — or click a concept then click the description.
Maps real-world resources to configuration
Plugin to interact with a specific cloud or service API
Container for multiple resources used together
Defines where state snapshots are stored
Executes scripts on local or remote machine during creation/destruction
Drag a concept onto its matching description — or click a concept then click the description.
Copy files to the remote resource
Run a script on the machine running Terraform
Run a script on the remote resource
Configure resource using Chef
Configure resource using Puppet
resource "aws_s3_bucket" "example" {}Output of `terraform state list`: aws_instance.web
Error: Could not satisfy version constraint for provider hashicorp/aws: required version >= 3.0, installed version 2.70
Error: creating EC2 Instance: InvalidParameterValue: Value (ami-0c55b159cbfafe1f0) for parameter ami is invalid. Expected: 'ami-...'. on main.tf line 22, in resource "aws_instance" "web": 22: ami = "ami-0c55b159cbfafe1f0"
$ terraform init Initializing the backend... Successfully configured the backend "s3"! Terraform will automatically use this backend unless the backend configuration changes. Error refreshing state: state data in S3 does not have the expected content. This may be due to a bug. If you are sure the state file is valid, run: terraform force-unlock <lock_id>
resource "aws_instance" "web" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
tags = {
Name = "WebServer"
}
}
resource "aws_eip" "web" {
instance = aws_instance.web.id
}terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "prod/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-locks"
encrypt = true
}
}
resource "aws_instance" "web" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
}$ terraform plan
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# aws_instance.web will be created
+ resource "aws_instance" "web" {
+ ami = "ami-0c55b159cbfafe1f0"
+ instance_type = "t2.micro"
+ tags = {
+ "Name" = "WebServer"
}
}
Plan: 1 to add, 0 to change, 0 to destroy.resource "aws_lb" "frontend" {
name = "frontend-alb"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.alb.id]
subnets = ["subnet-12345678", "subnet-87654321"]
}
resource "aws_lb_listener" "frontend_http" {
load_balancer_arn = aws_lb.frontend.arn
port = 80
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.frontend.arn
}
}
resource "aws_lb_target_group" "frontend" {
name = "frontend-tg"
port = 80
protocol = "HTTP"
vpc_id = "vpc-12345678"
}