Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 251


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?

Show Answer
Correct Answer: B

The most appropriate variable type for capturing configuration values for a server, where the values include both memory as a number and server name as a string, is an Object. In Terraform, the Object type allows the definition of variables that can contain multiple attributes, each with their own type. An example would be defining an object with a 'memory' attribute of type number and a 'name' attribute of type string.

Discussion

4 comments
Sign in to comment
Oleg_golOption: B
May 6, 2023

B https://developer.hashicorp.com/terraform/language/values/variables

seifsklOption: B
Jul 24, 2023

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).

SathisgmOption: B
May 9, 2023

I choose B

AWS_cert2023Option: B
Jun 22, 2023

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.