You have a list of numbers that represents the number of free CPU cores on each virtual cluster:
What Terraform function could you use to select the largest number from the list?
Correct Answer:
B
In Terraform, the max function can be used to select the largest number from a list of numbers. The max function takes multiple arguments and returns the highest one. For the list numcpus = [18, 3, 7, 11, 2], using max(numcpus...) will return 18, which is the largest number in the list.
References:
✑ Terraform documentation on max function: Terraform Functions - max
You can reference a resource created with for_each using a Splat ( *) expression.
Correct Answer:
B
You cannot reference a resource created with for_each using a splat (*) expression, as it will not work with resources that have non-numeric keys. You need to use a for expression instead to iterate over the resource instances.
You have declared a variable called var.list which is a list of objects that all have an attribute id . Which options will produce a list of the IDs? Choose two correct answers.
Correct Answer:
BC
These are two ways to produce a list of the IDs from a list of objects that have an attribute id, using either a for expression or a splat expression syntax.
What Terraform command always causes a state file to be updated with changes that might have been made outside of Terraform?
Correct Answer:
A
This is the command that always causes a state file to be updated with changes that might have been made outside of Terraform, as it will only refresh the state file with the current status of the real resources, without making any changes to them or creating a plan.
What does state looking accomplish?
Correct Answer:
B
This is what state locking accomplishes, by preventing other users from modifying the state file while a Terraform operation is in progress. This prevents conflicts and data loss.