Question 1110
An engineer tests the alltrue behavior in terraform console. What is the result of alltrue([true, true, false])?
- null
- 0
- true
- false
Explanation
Correct Answer
D:Evaluating the actual call alltrue([true, true, false]): alltrue is false whenever at least one input element is false; the third item is false.
Incorrect Answers
A:Given the specific operands supplied to the Terraform expression alltrue([true, true, false]), the function has a known boolean result because all list values are known.
B:Given the specific operands supplied to the Terraform expression alltrue([true, true, false]), the result is a boolean false, not the integer zero.
C:Given the specific operands supplied to the Terraform expression alltrue([true, true, false]), the last false element prevents an all-true result.
Question 1111
A Terraform 1.12 configuration evaluates length(values({z = "north", a = "south", m = "east"})). Which result follows from the expression as written?
- 2
- 5
- 1
- 3
Explanation
Correct Answer
D:For the specific expression length(values({z = "north", a = "south", m = "east"})), First, values follows the lexical ordering of the corresponding map keys; that produces exactly 3 elements; The outer length call counts those resulting elements rather than the original textual arguments.
Incorrect Answers
A:For the concrete expression length(values({z = "north", a = "south", m = "east"})), this drops one legitimate list element; the inner operation returns 3 values; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
B:For the concrete expression length(values({z = "north", a = "south", m = "east"})), the inner collection has 3 values, not 5; length counts the resulting collection only; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
C:In the calculation length(values({z = "north", a = "south", m = "east"})), 1 is not the size of the evaluated collection: the inner result has 3 elements, and length counts precisely those elements.
Question 1112
For Terraform string processing with suffix removal, evaluate trimsuffix("network.tf", ".tf"). Which output is correct?
- "network." (with original input formatting 2)
- "network.tf"
- "network"
- "tf"
Explanation
Correct Answer
C:Evaluating the actual call trimsuffix("network.tf", ".tf"): trimsuffix removes the entire matching .tf ending, leaving the base name network.
Incorrect Answers
A:Given the specific operands supplied to the Terraform expression trimsuffix("network.tf", ".tf"), the dot belongs to the suffix too, so keeping it would be incorrect.
B:Given the specific operands supplied to the Terraform expression trimsuffix("network.tf", ".tf"), the matching suffix must be omitted from the result.
D:Given the specific operands supplied to the Terraform expression trimsuffix("network.tf", ".tf"), the function returns the remaining string rather than the removed extension.
Question 1113
A Terraform 1.12 configuration evaluates join("/", values({z = "north", a = "south", m = "east"})). Which result follows from the expression as written?
- "south/east/north/north"
- "south/east/north"
- "southeastnorth"
- "north/east/south"
Explanation
Correct Answer
B:For the specific expression join("/", values({z = "north", a = "south", m = "east"})), First, values follows the lexical ordering of the corresponding map keys; The outer join uses a slash only between consecutive list members and preserves their computed order.
Incorrect Answers
A:For the concrete expression join("/", values({z = "north", a = "south", m = "east"})), join must not repeat the last item after the list has been joined; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
C:For the concrete expression join("/", values({z = "north", a = "south", m = "east"})), this omits the slash delimiters requested by join; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
D:For the concrete expression join("/", values({z = "north", a = "south", m = "east"})), this reverses the members even though join preserves the order returned by the inner expression; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
Question 1114
A Terraform 1.12 configuration evaluates reverse(values({z = "north", a = "south", m = "east"})). Which result follows from the expression as written?
- ["east", "north", "south"]
- ["east", "south", "north"]
- ["north", "east", "south"]
- ["south", "east", "north"]
Explanation
Correct Answer
C:For the specific expression reverse(values({z = "north", a = "south", m = "east"})), First, values follows the lexical ordering of the corresponding map keys; reverse then returns the exact opposite element order, without sorting or removing members.
Incorrect Answers
A:For the concrete expression reverse(values({z = "north", a = "south", m = "east"})), alphabetic sorting is not the same as reversing the sequence produced by the inner expression; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
B:For the concrete expression reverse(values({z = "north", a = "south", m = "east"})), this rotates the reversed list rather than returning the exact reversed sequence; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
D:For the concrete expression reverse(values({z = "north", a = "south", m = "east"})), this leaves the inner result unchanged and skips the outer reverse call; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
Question 1115
A Terraform 1.12 configuration evaluates sort(values({z = "north", a = "south", m = "east"})). Which result follows from the expression as written?
- ["north", "east", "south"]
- ["south", "east", "north"]
- ["south", "north", "east"]
- ["east", "north", "south"]
Explanation
Correct Answer
D:For the specific expression sort(values({z = "north", a = "south", m = "east"})), First, values follows the lexical ordering of the corresponding map keys; Terraform sort then compares the resulting strings lexicographically in ascending order; it neither drops values nor preserves a non-sorted arrangement.
Incorrect Answers
A:For the concrete expression sort(values({z = "north", a = "south", m = "east"})), a reversal is not guaranteed to produce ascending lexical order; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
B:For the concrete expression sort(values({z = "north", a = "south", m = "east"})), this retains the source order rather than explicitly sorting the result (unless it was already sorted); the inner stage produces ["south", "east", "north"] before the outer operation is applied.
C:For the concrete expression sort(values({z = "north", a = "south", m = "east"})), this puts strings in descending lexical order rather than ascending order; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
Question 1116
A Terraform 1.12 configuration evaluates element(values({z = "north", a = "south", m = "east"}), 4). Which result follows from the expression as written?
- "east"
- "south"
- "north"
- "index out of range"
Explanation
Correct Answer
A:For the specific expression element(values({z = "north", a = "south", m = "east"}), 4), First, values follows the lexical ordering of the corresponding map keys; The list has 3 entries, so element wraps index 4 modulo 3 and selects zero-based position one.
Incorrect Answers
B:For the concrete expression element(values({z = "north", a = "south", m = "east"}), 4), index wraparound lands at position one, not the first position of the inner list; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
C:For the concrete expression element(values({z = "north", a = "south", m = "east"}), 4), the final list member is not selected; the effective index is one; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
D:For the concrete expression element(values({z = "north", a = "south", m = "east"}), 4), element wraps a positive index instead of failing like ordinary square-bracket indexing; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
Question 1117
A Terraform 1.12 configuration evaluates slice(values({z = "north", a = "south", m = "east"}), 1, 3). Which result follows from the expression as written?
- ["north", "east"]
- ["east", "north"]
- ["south", "east", "north"]
- ["south", "east"]
Explanation
Correct Answer
B:For the specific expression slice(values({z = "north", a = "south", m = "east"}), 1, 3), First, values follows the lexical ordering of the corresponding map keys; slice begins at zero-based index one and continues through the final member, stopping before the exclusive end index 3.
Incorrect Answers
A:For the concrete expression slice(values({z = "north", a = "south", m = "east"}), 1, 3), slice preserves order rather than reversing the extracted portion; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
C:For the concrete expression slice(values({z = "north", a = "south", m = "east"}), 1, 3), this incorrectly keeps the first list member, although the slice begins at index one; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
D:For the concrete expression slice(values({z = "north", a = "south", m = "east"}), 1, 3), this takes an initial prefix rather than starting with the second entry; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
Question 1118
A Terraform 1.12 configuration evaluates format("primary=%s", element(values({z = "north", a = "south", m = "east"}), 0)). Which result follows from the expression as written?
- "south"
- "secondary=south"
- "primary=south"
- "primary=east"
Explanation
Correct Answer
C:For the specific expression format("primary=%s", element(values({z = "north", a = "south", m = "east"}), 0)), First, values follows the lexical ordering of the corresponding map keys; element at zero selects the first member, and the single %s placeholder in format substitutes that member after the literal primary= prefix.
Incorrect Answers
A:For the concrete expression format("primary=%s", element(values({z = "north", a = "south", m = "east"}), 0)), the format string has a literal primary= prefix that must appear in the result; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
B:For the concrete expression format("primary=%s", element(values({z = "north", a = "south", m = "east"}), 0)), the prefix is specified literally as primary= rather than secondary=; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
D:For the concrete expression format("primary=%s", element(values({z = "north", a = "south", m = "east"}), 0)), this uses the second list element; element at index zero selects the first value; the inner stage produces ["south", "east", "north"] before the outer operation is applied.
Question 1119
A Terraform 1.12 configuration evaluates length(formatlist("%s-%d", ["app", "db"], [1, 2])). Which result follows from the expression as written?
- 4
- 0
- 3
- 2
Explanation
Correct Answer
D:For the specific expression length(formatlist("%s-%d", ["app", "db"], [1, 2])), First, formatlist formats the corresponding elements of both lists position by position; that produces exactly 2 elements; The outer length call counts those resulting elements rather than the original textual arguments.
Incorrect Answers
A:For the concrete expression length(formatlist("%s-%d", ["app", "db"], [1, 2])), the inner collection has 2 values, not 4; length counts the resulting collection only; the inner stage produces ["app-1", "db-2"] before the outer operation is applied.
B:For the concrete expression length(formatlist("%s-%d", ["app", "db"], [1, 2])), the inner expression is not empty: it produces 2 elements; the inner stage produces ["app-1", "db-2"] before the outer operation is applied.
C:In the calculation length(formatlist("%s-%d", ["app", "db"], [1, 2])), 3 is not the size of the evaluated collection: the inner result has 2 elements, and length counts precisely those elements.
Question 1120
A Terraform 1.12 configuration evaluates join("/", formatlist("%s-%d", ["app", "db"], [1, 2])). Which result follows from the expression as written?
- "app-1/db-2"
- "app-1db-2"
- "db-2/app-1"
- "app-1/db-2/db-2"
Explanation
Correct Answer
A:For the specific expression join("/", formatlist("%s-%d", ["app", "db"], [1, 2])), First, formatlist formats the corresponding elements of both lists position by position; The outer join uses a slash only between consecutive list members and preserves their computed order.
Incorrect Answers
B:For the concrete expression join("/", formatlist("%s-%d", ["app", "db"], [1, 2])), this omits the slash delimiters requested by join; the inner stage produces ["app-1", "db-2"] before the outer operation is applied.
C:For the concrete expression join("/", formatlist("%s-%d", ["app", "db"], [1, 2])), this reverses the members even though join preserves the order returned by the inner expression; the inner stage produces ["app-1", "db-2"] before the outer operation is applied.
D:For the concrete expression join("/", formatlist("%s-%d", ["app", "db"], [1, 2])), join must not repeat the last item after the list has been joined; the inner stage produces ["app-1", "db-2"] before the outer operation is applied.