FCSS_CDS_AR-7.6 · Question #41
While working with Terraform files, an administrator notices that some of the variables do not have their type explicitly declared. What type of variable is vpccidr in the exhibit?
The correct answer is A. String. When a Terraform variable is declared without an explicit type argument, it defaults to string - making vpccidr (which likely holds a value like "10.0.0.0/16") a string by default. B (Set) is wrong because sets are complex collection types that must be explicitly declared with…
Question
While working with Terraform files, an administrator notices that some of the variables do not have their type explicitly declared. What type of variable is vpccidr in the exhibit?
Exhibit
Options
- AString
- BSet
- CMap
- DNumber
How the community answered
(44 responses)- A93% (41)
- C5% (2)
- D2% (1)
Explanation
When a Terraform variable is declared without an explicit type argument, it defaults to string - making vpccidr (which likely holds a value like "10.0.0.0/16") a string by default. B (Set) is wrong because sets are complex collection types that must be explicitly declared with type = set(...). C (Map) is wrong for the same reason - maps require type = map(...) and would need key-value pair syntax in the value. D (Number) is incorrect because a CIDR notation value contains dots and slashes, which are not valid numeric characters, and number types also require explicit declaration or a purely numeric value.
Memory tip: Think "string is the safe default" - just like untyped variables in many scripting languages become strings, Terraform follows the same convention. If you see no type = line in a variable block, it's always a string.
Topics
Community Discussion
No community discussion yet for this question.
