0
0
Terraformcloud~10 mins

Terraform file organization - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the main Terraform configuration file.

Terraform
resource "aws_instance" "example" {
  ami           = "ami-12345678"
  instance_type = "[1]"
}
Drag options to blanks, or click blank then click option'
At2.micro
Bt3.nano
Ct3.micro
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid instance types like 't3.nano' which may not be supported.
Typos in instance type string.
2fill in blank
medium

Complete the code to declare a variable for the AWS region.

Terraform
variable "region" {
  type    = string
  default = "[1]"
}
Drag options to blanks, or click blank then click option'
Aap-south-1
Bus-east-1
Ceu-central-1
Dus-west-2
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid region codes.
Forgetting to put the region in quotes.
3fill in blank
hard

Fix the error in the provider block to specify the AWS region variable.

Terraform
provider "aws" {
  region = [1]
}
Drag options to blanks, or click blank then click option'
Aregion
B"region"
Cvar.region
Daws_region
Attempts:
3 left
💡 Hint
Common Mistakes
Using the variable name without var. prefix.
Putting the variable name in quotes, making it a literal string.
4fill in blank
hard

Fill both blanks to create an output that shows the instance's public IP.

Terraform
output "instance_ip" {
  value = [1].[2]
}
Drag options to blanks, or click blank then click option'
Aaws_instance.example
Bpublic_ip
Cprivate_ip
Dinstance_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using private_ip instead of public_ip.
Referencing the wrong resource name.
5fill in blank
hard

Fill all three blanks to define a resource with a tag name and a count of 2.

Terraform
resource "aws_instance" "[1]" {
  ami           = "ami-12345678"
  instance_type = "t2.micro"
  count         = [2]
  tags = {
    Name = "[3]"
  }
}
Drag options to blanks, or click blank then click option'
Aweb_server
B2
CMyServer
Ddb_server
Attempts:
3 left
💡 Hint
Common Mistakes
Using count as a string instead of a number.
Mismatching resource name and tag name.