Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Terraform Associate All Questions

View all questions & answers for the Terraform Associate exam

Exam Terraform Associate topic 1 question 251 discussion

Actual exam question from HashiCorp's Terraform Associate
Question #: 251
Topic #: 1
[All Terraform Associate Questions]

You want to define a single input variable to capture configuration values for a server. The values must represent memory as a number, and the server name as a string.

Which variable type could you use for this input?

  • A. List
  • B. Object
  • C. Map
  • D. Terraform does not support complex input variables of different types
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
090200f
3 months, 3 weeks ago
Selected Answer: B
https://developer.hashicorp.com/terraform/language/values/variables#object https://developer.hashicorp.com/terraform/language/values/variables#map here mostly confusion about Object or map . but, Map: variable "image_id" { type = string description = "The id of the machine image (AMI) to use for the server." } eg: terraform apply -var='image_id_map={"us-east-1":"ami-abc123","us-east-2":"ami-def456"}' both key and value pair should be in string format only won't accept numbers where as Object: variable "docker_ports" { type = list(object({ internal = number external = number protocol = string })) default = [ { internal = 8300 external = 8300 protocol = "tcp" } ] } it can be any type var like number, string, bool So here B: Object is the correct option
upvoted 3 times
...
seifskl
1 year, 4 months ago
Selected Answer: B
B. Object The Object type in Terraform allows you to create complex input variables that contain more than one value and can be of different types. variable "server_config" { type = object({ memory = number name = string }) description = "Server configuration values" } In this example, server_config is an object that expects two attributes: memory (a number) and name (a string).
upvoted 2 times
...
AWS_cert2023
1 year, 5 months ago
Why not B not C? https://developer.hashicorp.com/terraform/language/expressions/type-constraints map(...): a collection of values where each is identified by a string label. object(...): a collection of named attributes that each have their own type. Values of map is string, values of object is any type.
upvoted 2 times
...
Sathisgm
1 year, 6 months ago
I choose B
upvoted 1 times
...
Oleg_gol
1 year, 6 months ago
Selected Answer: B
B https://developer.hashicorp.com/terraform/language/values/variables
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...