0
0
Terraformcloud~10 mins

Why HCL matters as Terraform's language - Test Your Understanding

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

Complete the code to define a Terraform provider block using HCL.

Terraform
provider "aws" {
  region = [1]
}
Drag options to blanks, or click blank then click option'
A"us-west-2"
Bus-west-2
C"aws-region"
Dregion
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put quotes around the region name
Using an undefined variable name without quotes
2fill in blank
medium

Complete the code to declare a Terraform variable with a default value in HCL.

Terraform
variable "instance_type" {
  type    = string
  default = [1]
}
Drag options to blanks, or click blank then click option'
At2.micro
Bt2_micro
Cmicro
D"t2.micro"
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around the default string value
Using underscores instead of dots in instance type
3fill in blank
hard

Fix the error in the Terraform resource block by completing the missing attribute value.

Terraform
resource "aws_instance" "example" {
  ami           = [1]
  instance_type = "t2.micro"
}
Drag options to blanks, or click blank then click option'
A"ami-123456"
Bami-123456
Cami_123456
D123456
Attempts:
3 left
💡 Hint
Common Mistakes
Using AMI ID without quotes
Replacing dashes with underscores
4fill in blank
hard

Fill both blanks to create a Terraform 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
Omitting the resource name before the attribute
5fill in blank
hard

Fill all three blanks to define a Terraform resource with tags using HCL.

Terraform
resource "aws_s3_bucket" "bucket" {
  bucket = [1]
  acl    = [2]
  tags = {
    Name        = [3]
  }
}
Drag options to blanks, or click blank then click option'
A"my-bucket"
B"private"
C"MyBucket"
D"public-read"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around string values
Using incorrect ACL values