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?
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?
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.
B https://developer.hashicorp.com/terraform/language/values/variables
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).
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.
I choose B