Question 1080
A Terraform 1.12 configuration evaluates reverse(sort(["west", "east", "central"])). Which result follows from the expression as written?
- ["west", "east", "central"]
- ["central", "east", "west"]
- ["east", "west", "central"]
- ["east", "central", "west"]
Explanation
Correct Answer
A:For the specific expression reverse(sort(["west", "east", "central"])), First, sort orders strings lexicographically; reverse then returns the exact opposite element order, without sorting or removing members.
Incorrect Answers
B:For the concrete expression reverse(sort(["west", "east", "central"])), this leaves the inner result unchanged and skips the outer reverse call; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
C:For the concrete expression reverse(sort(["west", "east", "central"])), rotating the input left one position does not invert every position as reverse requires; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
D:For the concrete expression reverse(sort(["west", "east", "central"])), this rotates the reversed list rather than returning the exact reversed sequence; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
Question 1081
A Terraform 1.12 configuration evaluates sort(sort(["west", "east", "central"])). Which result follows from the expression as written?
- ["east", "west", "central"]
- ["central", "east", "west"]
- ["west", "east", "central"]
- ["central", "east"]
Explanation
Correct Answer
B:For the specific expression sort(sort(["west", "east", "central"])), First, sort orders strings lexicographically; 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(sort(["west", "east", "central"])), this rotates entries rather than sorting them lexicographically; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
C:For the concrete expression sort(sort(["west", "east", "central"])), a reversal is not guaranteed to produce ascending lexical order; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
D:For the concrete expression sort(sort(["west", "east", "central"])), sorting does not remove the final element of the list; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
Question 1082
An engineer tests the coalescelist behavior in terraform console. What is the result of coalescelist([], ["primary", "secondary"], ["fallback"])?
- ["primary", "secondary"]
- ["fallback"]
- ["primary"]
- []
Explanation
Correct Answer
A:Evaluating the actual call coalescelist([], ["primary", "secondary"], ["fallback"]): coalescelist selects the first nonempty list argument, which is the two-element primary list.
Incorrect Answers
B:Given the specific operands supplied to the Terraform expression coalescelist([], ["primary", "secondary"], ["fallback"]), the last list is not used because an earlier nonempty list exists.
C:Given the specific operands supplied to the Terraform expression coalescelist([], ["primary", "secondary"], ["fallback"]), coalescelist returns the chosen entire list, not only its first item.
D:Given the specific operands supplied to the Terraform expression coalescelist([], ["primary", "secondary"], ["fallback"]), the first argument is empty, so coalescelist skips it.
Question 1083
A Terraform 1.12 configuration evaluates element(sort(["west", "east", "central"]), 4). Which result follows from the expression as written?
- "central"
- "west"
- "index out of range"
- "east"
Explanation
Correct Answer
D:For the specific expression element(sort(["west", "east", "central"]), 4), First, sort orders strings lexicographically; 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(sort(["west", "east", "central"]), 4), index wraparound lands at position one, not the first position of the inner list; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
B:For the concrete expression element(sort(["west", "east", "central"]), 4), the final list member is not selected; the effective index is one; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
C:For the concrete expression element(sort(["west", "east", "central"]), 4), element wraps a positive index instead of failing like ordinary square-bracket indexing; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
Question 1084
For Terraform string processing with string replacement, evaluate replace("db.dev.internal", ".", "-"). Which output is correct?
- "db-dev-internal"
- "db_dev_internal" (with original input formatting 3)
- "db-dev.internal" (with original input formatting 2)
- "db.dev.internal" (with original input formatting 1)
Explanation
Correct Answer
A:Evaluating the actual call replace("db.dev.internal", ".", "-"): replace substitutes each period in the source with a hyphen, producing db-dev-internal.
Incorrect Answers
B:Given the specific operands supplied to the Terraform expression replace("db.dev.internal", ".", "-"), the replacement argument is a hyphen, not an underscore.
C:Given the specific operands supplied to the Terraform expression replace("db.dev.internal", ".", "-"), this changes only the first period, but replace substitutes all matching occurrences.
D:Given the specific operands supplied to the Terraform expression replace("db.dev.internal", ".", "-"), the matching period characters should be replaced rather than preserved.
Question 1085
A Terraform 1.12 configuration evaluates slice(sort(["west", "east", "central"]), 1, 3). Which result follows from the expression as written?
- ["west", "east"]
- ["east", "west"]
- ["central", "east", "west"]
- ["central", "east"]
Explanation
Correct Answer
B:For the specific expression slice(sort(["west", "east", "central"]), 1, 3), First, sort orders strings lexicographically; 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(sort(["west", "east", "central"]), 1, 3), slice preserves order rather than reversing the extracted portion; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
C:For the concrete expression slice(sort(["west", "east", "central"]), 1, 3), this incorrectly keeps the first list member, although the slice begins at index one; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
D:For the concrete expression slice(sort(["west", "east", "central"]), 1, 3), this takes an initial prefix rather than starting with the second entry; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
Question 1086
A Terraform 1.12 configuration evaluates format("primary=%s", element(sort(["west", "east", "central"]), 0)). Which result follows from the expression as written?
- "central"
- "secondary=central"
- "primary=central"
- "primary=east"
Explanation
Correct Answer
C:For the specific expression format("primary=%s", element(sort(["west", "east", "central"]), 0)), First, sort orders strings lexicographically; 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(sort(["west", "east", "central"]), 0)), the format string has a literal primary= prefix that must appear in the result; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
B:For the concrete expression format("primary=%s", element(sort(["west", "east", "central"]), 0)), the prefix is specified literally as primary= rather than secondary=; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
D:For the concrete expression format("primary=%s", element(sort(["west", "east", "central"]), 0)), this uses the second list element; element at index zero selects the first value; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
Question 1087
A Terraform 1.12 configuration evaluates length(flatten([["g1"], ["g2", "g3"]])). Which result follows from the expression as written?
- 5
- 0
- 4
- 3
Explanation
Correct Answer
D:For the specific expression length(flatten([["g1"], ["g2", "g3"]])), First, flatten removes nested list boundaries without changing member sequence; 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(flatten([["g1"], ["g2", "g3"]])), the inner collection has 3 values, not 5; length counts the resulting collection only; the inner stage produces ["g1", "g2", "g3"] before the outer operation is applied.
B:For the concrete expression length(flatten([["g1"], ["g2", "g3"]])), the inner expression is not empty: it produces 3 elements; the inner stage produces ["g1", "g2", "g3"] before the outer operation is applied.
C:In the calculation length(flatten([["g1"], ["g2", "g3"]])), 4 is not the size of the evaluated collection: the inner result has 3 elements, and length counts precisely those elements.
Question 1088
A Terraform 1.12 configuration evaluates join("/", flatten([["g1"], ["g2", "g3"]])). Which result follows from the expression as written?
- "g1/g2/g3"
- "g1g2g3"
- "g3/g2/g1"
- "g1/g2/g3/g3"
Explanation
Correct Answer
A:For the specific expression join("/", flatten([["g1"], ["g2", "g3"]])), First, flatten removes nested list boundaries without changing member sequence; The outer join uses a slash only between consecutive list members and preserves their computed order.
Incorrect Answers
B:For the concrete expression join("/", flatten([["g1"], ["g2", "g3"]])), this omits the slash delimiters requested by join; the inner stage produces ["g1", "g2", "g3"] before the outer operation is applied.
C:For the concrete expression join("/", flatten([["g1"], ["g2", "g3"]])), this reverses the members even though join preserves the order returned by the inner expression; the inner stage produces ["g1", "g2", "g3"] before the outer operation is applied.
D:For the concrete expression join("/", flatten([["g1"], ["g2", "g3"]])), join must not repeat the last item after the list has been joined; the inner stage produces ["g1", "g2", "g3"] before the outer operation is applied.
Question 1089
A Terraform 1.12 configuration evaluates reverse(flatten([["g1"], ["g2", "g3"]])). Which result follows from the expression as written?
- ["g2", "g1", "g3"]
- ["g3", "g2", "g1"]
- ["g1", "g2", "g3"]
- ["g2", "g3", "g1"]
Explanation
Correct Answer
B:For the specific expression reverse(flatten([["g1"], ["g2", "g3"]])), First, flatten removes nested list boundaries without changing member sequence; reverse then returns the exact opposite element order, without sorting or removing members.
Incorrect Answers
A:For the concrete expression reverse(flatten([["g1"], ["g2", "g3"]])), this rotates the reversed list rather than returning the exact reversed sequence; the inner stage produces ["g1", "g2", "g3"] before the outer operation is applied.
C:For the concrete expression reverse(flatten([["g1"], ["g2", "g3"]])), this leaves the inner result unchanged and skips the outer reverse call; the inner stage produces ["g1", "g2", "g3"] before the outer operation is applied.
D:For the concrete expression reverse(flatten([["g1"], ["g2", "g3"]])), rotating the input left one position does not invert every position as reverse requires; the inner stage produces ["g1", "g2", "g3"] before the outer operation is applied.
Question 1090
A Terraform 1.12 configuration evaluates sort(flatten([["g1"], ["g2", "g3"]])). Which result follows from the expression as written?
- ["g1", "g2"]
- ["g2", "g3", "g1"]
- ["g1", "g2", "g3"]
- ["g3", "g2", "g1"]
Explanation
Correct Answer
C:For the specific expression sort(flatten([["g1"], ["g2", "g3"]])), First, flatten removes nested list boundaries without changing member sequence; 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(flatten([["g1"], ["g2", "g3"]])), sorting does not remove the final element of the list; the inner stage produces ["g1", "g2", "g3"] before the outer operation is applied.
B:For the concrete expression sort(flatten([["g1"], ["g2", "g3"]])), this rotates entries rather than sorting them lexicographically; the inner stage produces ["g1", "g2", "g3"] before the outer operation is applied.
D:For the concrete expression sort(flatten([["g1"], ["g2", "g3"]])), a reversal is not guaranteed to produce ascending lexical order; the inner stage produces ["g1", "g2", "g3"] before the outer operation is applied.