Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 212


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?

Show Answer
Correct Answer: A

To select the largest number from a list in Terraform, you use the max function. The max function takes one or more numbers and returns the greatest number from the set. For the list of CPU cores, max(numcpus) will return the highest value, which is the desired outcome. Other options such as ceil, top, or high are not valid functions for this purpose in Terraform.

Discussion

3 comments
Sign in to comment
gekkehenkOption: A
Jan 14, 2023

"max takes one or more numbers and returns the greatest number from the set."

ArizonaClassics
Jan 14, 2023

A is correct See https://developer.hashicorp.com/terraform/language/functions/max

090200fOption: A
Jul 28, 2024

> ceil(5) 5 > ceil(5.1) 6 > max(12, 54, 3) 54 seems like there is no top and high functions.. so answer is max(...) A. https://developer.hashicorp.com/terraform/language/functions/max