Question 1100
A Terraform 1.12 configuration evaluates element(slice(["a", "b", "c", "d"], 1, 4), 4). Which result follows from the expression as written?
- "c"
- "b"
- "d"
- "index out of range"
Explanation
Correct Answer
A:For the specific expression element(slice(["a", "b", "c", "d"], 1, 4), 4), First, slice includes the start index and excludes the end index; 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(slice(["a", "b", "c", "d"], 1, 4), 4), index wraparound lands at position one, not the first position of the inner list; the inner stage produces ["b", "c", "d"] before the outer operation is applied.
C:For the concrete expression element(slice(["a", "b", "c", "d"], 1, 4), 4), the final list member is not selected; the effective index is one; the inner stage produces ["b", "c", "d"] before the outer operation is applied.
D:For the concrete expression element(slice(["a", "b", "c", "d"], 1, 4), 4), element wraps a positive index instead of failing like ordinary square-bracket indexing; the inner stage produces ["b", "c", "d"] before the outer operation is applied.
Question 1101
A Terraform 1.12 configuration evaluates slice(slice(["a", "b", "c", "d"], 1, 4), 1, 3). Which result follows from the expression as written?
- ["d", "c"]
- ["c", "d"]
- ["b", "c", "d"]
- ["b", "c"]
Explanation
Correct Answer
B:For the specific expression slice(slice(["a", "b", "c", "d"], 1, 4), 1, 3), First, slice includes the start index and excludes the end index; 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(slice(["a", "b", "c", "d"], 1, 4), 1, 3), slice preserves order rather than reversing the extracted portion; the inner stage produces ["b", "c", "d"] before the outer operation is applied.
C:For the concrete expression slice(slice(["a", "b", "c", "d"], 1, 4), 1, 3), this incorrectly keeps the first list member, although the slice begins at index one; the inner stage produces ["b", "c", "d"] before the outer operation is applied.
D:For the concrete expression slice(slice(["a", "b", "c", "d"], 1, 4), 1, 3), this takes an initial prefix rather than starting with the second entry; the inner stage produces ["b", "c", "d"] before the outer operation is applied.
Question 1102
A Terraform 1.12 configuration evaluates format("primary=%s", element(slice(["a", "b", "c", "d"], 1, 4), 0)). Which result follows from the expression as written?
- "b"
- "secondary=b"
- "primary=b"
- "primary=c"
Explanation
Correct Answer
C:For the specific expression format("primary=%s", element(slice(["a", "b", "c", "d"], 1, 4), 0)), First, slice includes the start index and excludes the end index; 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(slice(["a", "b", "c", "d"], 1, 4), 0)), the format string has a literal primary= prefix that must appear in the result; the inner stage produces ["b", "c", "d"] before the outer operation is applied.
B:For the concrete expression format("primary=%s", element(slice(["a", "b", "c", "d"], 1, 4), 0)), the prefix is specified literally as primary= rather than secondary=; the inner stage produces ["b", "c", "d"] before the outer operation is applied.
D:For the concrete expression format("primary=%s", element(slice(["a", "b", "c", "d"], 1, 4), 0)), this uses the second list element; element at index zero selects the first value; the inner stage produces ["b", "c", "d"] before the outer operation is applied.
Question 1103
A Terraform 1.12 configuration evaluates length(keys({z = 1, a = 2, m = 3})). Which result follows from the expression as written?
- 4
- 1
- 5
- 3
Explanation
Correct Answer
D:For the specific expression length(keys({z = 1, a = 2, m = 3})), First, keys returns map keys in lexicographic order; 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(keys({z = 1, a = 2, m = 3})), this counts one element beyond the 3 values produced by the inner expression; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
B:In the calculation length(keys({z = 1, a = 2, m = 3})), 1 is not the size of the evaluated collection: the inner result has 3 elements, and length counts precisely those elements.
C:For the concrete expression length(keys({z = 1, a = 2, m = 3})), the inner collection has 3 values, not 5; length counts the resulting collection only; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
Question 1104
A Terraform 1.12 configuration evaluates join("/", keys({z = 1, a = 2, m = 3})). Which result follows from the expression as written?
- "a/m/z"
- "amz"
- "z/m/a"
- "a/m/z/z"
Explanation
Correct Answer
A:For the specific expression join("/", keys({z = 1, a = 2, m = 3})), First, keys returns map keys in lexicographic order; The outer join uses a slash only between consecutive list members and preserves their computed order.
Incorrect Answers
B:For the concrete expression join("/", keys({z = 1, a = 2, m = 3})), this omits the slash delimiters requested by join; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
C:For the concrete expression join("/", keys({z = 1, a = 2, m = 3})), this reverses the members even though join preserves the order returned by the inner expression; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
D:For the concrete expression join("/", keys({z = 1, a = 2, m = 3})), join must not repeat the last item after the list has been joined; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
Question 1105
A Terraform 1.12 configuration evaluates reverse(keys({z = 1, a = 2, m = 3})). Which result follows from the expression as written?
- ["m", "a", "z"]
- ["z", "m", "a"]
- ["a", "m", "z"]
- ["m", "z", "a"]
Explanation
Correct Answer
B:For the specific expression reverse(keys({z = 1, a = 2, m = 3})), First, keys returns map keys in lexicographic order; reverse then returns the exact opposite element order, without sorting or removing members.
Incorrect Answers
A:For the concrete expression reverse(keys({z = 1, a = 2, m = 3})), this rotates the reversed list rather than returning the exact reversed sequence; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
C:For the concrete expression reverse(keys({z = 1, a = 2, m = 3})), this leaves the inner result unchanged and skips the outer reverse call; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
D:For the concrete expression reverse(keys({z = 1, a = 2, m = 3})), rotating the input left one position does not invert every position as reverse requires; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
Question 1106
A Terraform 1.12 configuration evaluates sort(keys({z = 1, a = 2, m = 3})). Which result follows from the expression as written?
- ["a", "m"]
- ["m", "z", "a"]
- ["a", "m", "z"]
- ["z", "m", "a"]
Explanation
Correct Answer
C:For the specific expression sort(keys({z = 1, a = 2, m = 3})), First, keys returns map keys in lexicographic order; 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(keys({z = 1, a = 2, m = 3})), sorting does not remove the final element of the list; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
B:For the concrete expression sort(keys({z = 1, a = 2, m = 3})), this rotates entries rather than sorting them lexicographically; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
D:For the concrete expression sort(keys({z = 1, a = 2, m = 3})), a reversal is not guaranteed to produce ascending lexical order; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
Question 1107
A Terraform 1.12 configuration evaluates element(keys({z = 1, a = 2, m = 3}), 4). Which result follows from the expression as written?
- "a"
- "z"
- "index out of range"
- "m"
Explanation
Correct Answer
D:For the specific expression element(keys({z = 1, a = 2, m = 3}), 4), First, keys returns map keys in lexicographic order; The list has 3 entries, so element wraps index 4 modulo 3 and selects zero-based position one.
Incorrect Answers
A:For the concrete expression element(keys({z = 1, a = 2, m = 3}), 4), index wraparound lands at position one, not the first position of the inner list; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
B:For the concrete expression element(keys({z = 1, a = 2, m = 3}), 4), the final list member is not selected; the effective index is one; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
C:For the concrete expression element(keys({z = 1, a = 2, m = 3}), 4), element wraps a positive index instead of failing like ordinary square-bracket indexing; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
Question 1108
A Terraform 1.12 configuration evaluates slice(keys({z = 1, a = 2, m = 3}), 1, 3). Which result follows from the expression as written?
- ["m", "z"]
- ["a", "m", "z"]
- ["a", "m"]
- ["z", "m"]
Explanation
Correct Answer
A:For the specific expression slice(keys({z = 1, a = 2, m = 3}), 1, 3), First, keys returns map keys in lexicographic order; slice begins at zero-based index one and continues through the final member, stopping before the exclusive end index 3.
Incorrect Answers
B:For the concrete expression slice(keys({z = 1, a = 2, m = 3}), 1, 3), this incorrectly keeps the first list member, although the slice begins at index one; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
C:For the concrete expression slice(keys({z = 1, a = 2, m = 3}), 1, 3), this takes an initial prefix rather than starting with the second entry; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
D:For the concrete expression slice(keys({z = 1, a = 2, m = 3}), 1, 3), slice preserves order rather than reversing the extracted portion; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
Question 1109
A Terraform 1.12 configuration evaluates format("primary=%s", element(keys({z = 1, a = 2, m = 3}), 0)). Which result follows from the expression as written?
- "secondary=a"
- "primary=a"
- "primary=m"
- "a"
Explanation
Correct Answer
B:For the specific expression format("primary=%s", element(keys({z = 1, a = 2, m = 3}), 0)), First, keys returns map keys in lexicographic order; 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(keys({z = 1, a = 2, m = 3}), 0)), the prefix is specified literally as primary= rather than secondary=; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
C:For the concrete expression format("primary=%s", element(keys({z = 1, a = 2, m = 3}), 0)), this uses the second list element; element at index zero selects the first value; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
D:For the concrete expression format("primary=%s", element(keys({z = 1, a = 2, m = 3}), 0)), the format string has a literal primary= prefix that must appear in the result; the inner stage produces ["a", "m", "z"] before the outer operation is applied.
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.