TERRAFORM-ASSOCIATE-003 practice question 11 of 30
[Understand Terraform Basics and CLI] You have a list of numbers that represents the number of free CPU cores on each virtual cluster: numcpus = [ 18, 3, 7, 11, 2 ] What Terraform function could you use to select the largest number from the list? [numcpus]
Full set: 226 questionsThe max function is a built-in Terraform numeric function that takes one or more numbers as arguments and returns the greatest number from the set. To use it with a list of numbers, such as the numcpus variable, you would use the expand (...) symbol to pass the list elements as individual arguments to the function (e.g., max(var.numcpus...)). This will correctly identify and return the largest value from the list, which is 18 in this case.
A. top(numcpus): top is not a valid built-in function in the Terraform language.
C. ceil(numcpus): The ceil function is used to round a single fractional number up to the next whole number. It cannot be used to find the maximum value in a list.
D. hight: hight is not a valid Terraform function. It appears to be a misspelling of "high".
1. HashiCorp. (n.d.). Terraform Functions - max. Terraform by HashiCorp. Retrieved from https://developer.hashicorp.com/terraform/language/functions/max.
Section: max Function Documentation. This page explicitly states
"max takes one or more numbers and returns the greatest number from the set." It also provides an example of using it with a list.
2. HashiCorp. (n.d.). Terraform Functions - ceil. Terraform by HashiCorp. Retrieved from https://developer.hashicorp.com/terraform/language/functions/ceil.
Section: ceil Function Documentation. This source defines ceil as a function that "returns the closest whole number that is greater than or equal to the given value
" confirming it is for rounding
not for list comparison.
3. HashiCorp. (n.d.). Terraform Functions. Terraform by HashiCorp. Retrieved from https://developer.hashicorp.com/terraform/language/functions.
Section: All Functions. This index of all built-in functions confirms that top and hight do not exist in the Terraform language.
Keep practicing
Take the free TERRAFORM-ASSOCIATE-003 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other TERRAFORM-ASSOCIATE-003 practice questions
- Question 1[Understand Terraform Basics and CLI] If you update the version constraint in your Terraf…
- Question 2[Navigate Terraform State and Backends] Terraform variable names are saved in the state f…
- Question 3[Understand Terraform Basics and CLI] You modified your Terraform configuration and run T…
- Question 4[Understand Terraform Basics and CLI] You must use different Terraform commands depending…
- Question 6[Understand Terraform Basics and CLI] terraform init creates an example main.tf file in t…
- Question 7[Understand Terraform Basics and CLI] terraform validate confirms that your infrastructur…
