0
0
Terraformcloud~20 mins

Object type definition in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform Object Type Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Configuration
intermediate
2:00remaining
Identify the correct Terraform object type definition
Which option correctly defines a Terraform object type with a string field name and a number field count?
Aobject({ name: string, count: number })
Bobject({ name = string, count = number })
Cobject([name = string, count = number])
Dobject({ "name" = string, "count" = number })
Attempts:
2 left
💡 Hint
Terraform object types use curly braces with key = type pairs.
service_behavior
intermediate
2:00remaining
What happens if a Terraform object type is missing a required attribute?
Given a Terraform object type object({ name = string, count = number }), what error occurs if you provide an object missing the count attribute?
ATerraform plan throws a syntax error.
BTerraform plan succeeds but sets 'count' to zero by default.
CTerraform plan ignores the missing attribute and continues.
DTerraform plan fails with a validation error about missing attribute 'count'.
Attempts:
2 left
💡 Hint
Terraform enforces required attributes in object types strictly.
Architecture
advanced
2:30remaining
Choose the correct nested object type definition in Terraform
Which option correctly defines a Terraform object type with a string name and a nested object settings containing a boolean enabled and a list of strings tags?
Aobject({ name = string, settings = object({ enabled = bool, tags = list(string) }) })
Bobject({ name = string, settings = object([ enabled = bool, tags = list(string) ]) })
Cobject({ name = string, settings = { enabled = bool, tags = list(string) } })
Dobject({ name = string, settings = map({ enabled = bool, tags = list(string) }) })
Attempts:
2 left
💡 Hint
Nested objects use object() with curly braces inside the parent object definition.
security
advanced
2:00remaining
What is the security implication of using any type instead of a strict object type in Terraform?
If you replace a strict object type with any in Terraform variable definitions, what is the main security risk?
AIt allows any data structure, potentially leading to unexpected or unsafe configurations.
BIt encrypts all data automatically, increasing security.
CIt causes Terraform to ignore the variable during plan.
DIt restricts input to only strings, reducing flexibility.
Attempts:
2 left
💡 Hint
Using any disables type checking.
Best Practice
expert
3:00remaining
Which Terraform object type definition best enforces immutability of a configuration block?
You want to define a Terraform object type for a configuration block that should not allow extra attributes beyond id (string) and enabled (bool). Which option enforces this strictly?
Amap(any)
Bobject({ id = string, enabled = bool, optional = true })
Cobject({ id = string, enabled = bool })
Dobject({ id = string, enabled = bool, additional_properties = false })
Attempts:
2 left
💡 Hint
Terraform object types do not support additional properties by default.