0
0
Terraformcloud~10 mins

Block syntax and structure in Terraform - 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 a resource block in Terraform.

Terraform
resource "aws_instance" "example" [1]
  ami           = "ami-12345678"
  instance_type = "t2.micro"
Drag options to blanks, or click blank then click option'
A<
B[
C{
D(
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets instead of curly braces.
Using parentheses instead of curly braces.
2fill in blank
medium

Complete the code to close the resource block correctly.

Terraform
resource "aws_instance" "example" {
  ami           = "ami-12345678"
  instance_type = "t2.micro"
[1]
Drag options to blanks, or click blank then click option'
A}
B[
C)
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets or parentheses to close the block.
Forgetting to close the block.
3fill in blank
hard

Fix the error in the block syntax by completing the code.

Terraform
variable "region" [1] 
  default = "us-west-2"
}
Drag options to blanks, or click blank then click option'
A<
B[
C(
D{
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets or parentheses instead of curly braces.
Missing the opening brace.
4fill in blank
hard

Fill both blanks to complete the nested block structure.

Terraform
resource "aws_security_group" "example" [1]
  ingress [2] 
    from_port   = 80
    to_port     = 80
    protocol    = "tcp"
  }
}
Drag options to blanks, or click blank then click option'
A{
B[
C}
D(
Attempts:
3 left
💡 Hint
Common Mistakes
Using different types of brackets for nested blocks.
Mismatching opening and closing braces.
5fill in blank
hard

Fill all three blanks to complete the provider block with nested configuration.

Terraform
provider "aws" [1]
  region = "us-east-1"
  assume_role [2] 
    role_arn = "arn:aws:iam::123456789012:role/example"
  [3]
}
Drag options to blanks, or click blank then click option'
A{
C}
D]
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets or other symbols instead of curly braces.
Forgetting to close the nested block.