0
0
Terraformcloud~10 mins

Object type definition 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 an object type with a string attribute named 'name'.

Terraform
variable "user" {
  type = object({
    name = [1]
  })
}
Drag options to blanks, or click blank then click option'
Astring
Bnumber
Cbool
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'number' or 'bool' instead of 'string' for text attributes.
2fill in blank
medium

Complete the code to add an integer attribute 'age' to the object type.

Terraform
variable "person" {
  type = object({
    name = string,
    age  = [1]
  })
}
Drag options to blanks, or click blank then click option'
Anumber
Bstring
Cbool
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'string' type for numeric attributes.
3fill in blank
hard

Fix the error in the object type definition by completing the missing type for 'active'.

Terraform
variable "account" {
  type = object({
    username = string,
    active   = [1]
  })
}
Drag options to blanks, or click blank then click option'
Alist
Bnumber
Cstring
Dbool
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'string' or 'number' instead of 'bool' for boolean attributes.
4fill in blank
hard

Fill both blanks to define an object with a string 'id' and a list of strings 'tags'.

Terraform
variable "resource" {
  type = object({
    id   = [1],
    tags = [2]
  })
}
Drag options to blanks, or click blank then click option'
Astring
Blist(string)
Cbool
Dnumber
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'list' without specifying the element type.
Using 'string' for the 'tags' list.
5fill in blank
hard

Fill all three blanks to define an object with 'name' (string), 'count' (number), and 'enabled' (bool).

Terraform
variable "config" {
  type = object({
    name    = [1],
    count   = [2],
    enabled = [3]
  })
}
Drag options to blanks, or click blank then click option'
Abool
Bnumber
Cstring
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up types between attributes.
Using 'list' instead of primitive types.