Question 1160
A Terraform 1.12 configuration evaluates length(split(":", "auth:read:write")). Which result follows from the expression as written?
- 3
- 5
- 1
- 6
Explanation
Correct Answer
A:For the specific expression length(split(":", "auth:read:write")), First, split separates the three colon-delimited fields in input order; that produces exactly 3 elements; The outer length call counts those resulting elements rather than the original textual arguments.
Incorrect Answers
B:In the calculation length(split(":", "auth:read:write")), 5 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(split(":", "auth:read:write")), there is more than one retained element after the inner calculation; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
D:For the concrete expression length(split(":", "auth:read:write")), no stage of the expression creates 6 list elements; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
Question 1161
A Terraform 1.12 configuration evaluates join("/", split(":", "auth:read:write")). Which result follows from the expression as written?
- "auth/read/write/write"
- "auth/read/write"
- "authreadwrite"
- "write/read/auth"
Explanation
Correct Answer
B:For the specific expression join("/", split(":", "auth:read:write")), First, split separates the three colon-delimited fields in input order; The outer join uses a slash only between consecutive list members and preserves their computed order.
Incorrect Answers
A:For the concrete expression join("/", split(":", "auth:read:write")), join must not repeat the last item after the list has been joined; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
C:For the concrete expression join("/", split(":", "auth:read:write")), this omits the slash delimiters requested by join; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
D:For the concrete expression join("/", split(":", "auth:read:write")), this reverses the members even though join preserves the order returned by the inner expression; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
Question 1162
A Terraform 1.12 configuration evaluates reverse(split(":", "auth:read:write")). Which result follows from the expression as written?
- ["read", "write", "auth"]
- ["read", "auth", "write"]
- ["write", "read", "auth"]
- ["auth", "read", "write"]
Explanation
Correct Answer
C:For the specific expression reverse(split(":", "auth:read:write")), First, split separates the three colon-delimited fields in input order; reverse then returns the exact opposite element order, without sorting or removing members.
Incorrect Answers
A:For the concrete expression reverse(split(":", "auth:read:write")), rotating the input left one position does not invert every position as reverse requires; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
B:For the concrete expression reverse(split(":", "auth:read:write")), this rotates the reversed list rather than returning the exact reversed sequence; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
D:For the concrete expression reverse(split(":", "auth:read:write")), this leaves the inner result unchanged and skips the outer reverse call; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
Question 1163
A Terraform 1.12 configuration evaluates sort(split(":", "auth:read:write")). Which result follows from the expression as written?
- ["write", "read", "auth"]
- ["auth", "read"]
- ["read", "write", "auth"]
- ["auth", "read", "write"]
Explanation
Correct Answer
D:For the specific expression sort(split(":", "auth:read:write")), First, split separates the three colon-delimited fields in input 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(split(":", "auth:read:write")), a reversal is not guaranteed to produce ascending lexical order; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
B:For the concrete expression sort(split(":", "auth:read:write")), sorting does not remove the final element of the list; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
C:For the concrete expression sort(split(":", "auth:read:write")), this rotates entries rather than sorting them lexicographically; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
Question 1164
A Terraform 1.12 configuration evaluates element(split(":", "auth:read:write"), 4). Which result follows from the expression as written?
- "read"
- "auth"
- "write"
- "index out of range"
Explanation
Correct Answer
A:For the specific expression element(split(":", "auth:read:write"), 4), First, split separates the three colon-delimited fields in input order; 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(split(":", "auth:read:write"), 4), index wraparound lands at position one, not the first position of the inner list; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
C:For the concrete expression element(split(":", "auth:read:write"), 4), the final list member is not selected; the effective index is one; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
D:For the concrete expression element(split(":", "auth:read:write"), 4), element wraps a positive index instead of failing like ordinary square-bracket indexing; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
Question 1165
A Terraform 1.12 configuration evaluates slice(split(":", "auth:read:write"), 1, 3). Which result follows from the expression as written?
- ["write", "read"]
- ["read", "write"]
- ["auth", "read", "write"]
- ["auth", "read"]
Explanation
Correct Answer
B:For the specific expression slice(split(":", "auth:read:write"), 1, 3), First, split separates the three colon-delimited fields in input order; 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(split(":", "auth:read:write"), 1, 3), slice preserves order rather than reversing the extracted portion; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
C:For the concrete expression slice(split(":", "auth:read:write"), 1, 3), this incorrectly keeps the first list member, although the slice begins at index one; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
D:For the concrete expression slice(split(":", "auth:read:write"), 1, 3), this takes an initial prefix rather than starting with the second entry; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
Question 1166
An engineer tests the starts-with behavior in terraform console. What is the result of startswith("network-prod", "net")?
- true
- "network"
- "net"
- false
Explanation
Correct Answer
A:Evaluating the actual call startswith("network-prod", "net"): The value network-prod begins with the exact prefix net, so startswith evaluates to true.
Incorrect Answers
B:Given the specific operands supplied to the Terraform expression startswith("network-prod", "net"), the function checks and reports whether a prefix exists; it does not return the matching word.
C:Given the specific operands supplied to the Terraform expression startswith("network-prod", "net"), startswith returns a boolean match result, not the searched prefix.
D:Given the specific operands supplied to the Terraform expression startswith("network-prod", "net"), the supplied prefix is the first three characters of the string.
Question 1167
A Terraform 1.12 configuration evaluates format("primary=%s", element(split(":", "auth:read:write"), 0)). Which result follows from the expression as written?
- "primary=read"
- "auth"
- "secondary=auth"
- "primary=auth"
Explanation
Correct Answer
D:For the specific expression format("primary=%s", element(split(":", "auth:read:write"), 0)), First, split separates the three colon-delimited fields in input 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(split(":", "auth:read:write"), 0)), this uses the second list element; element at index zero selects the first value; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
B:For the concrete expression format("primary=%s", element(split(":", "auth:read:write"), 0)), the format string has a literal primary= prefix that must appear in the result; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
C:For the concrete expression format("primary=%s", element(split(":", "auth:read:write"), 0)), the prefix is specified literally as primary= rather than secondary=; the inner stage produces ["auth", "read", "write"] before the outer operation is applied.
Question 1168
For Terraform string processing with trim both ends, evaluate trim("...prod...", "."). Which output is correct?
- "...prod..." (input left unchanged)
- "prod..." (with original input formatting 1)
- "prod"
- "...prod" (with original input formatting 2)
Explanation
Correct Answer
C:Evaluating the actual call trim("...prod...", "."): trim removes period characters from both ends of the input string, leaving the untouched middle prod.
Incorrect Answers
A:Given the specific operands supplied to the Terraform expression trim("...prod...", "."), this is the unmodified input and leaves the periods that the function removes.
B:Given the specific operands supplied to the Terraform expression trim("...prod...", "."), trailing periods must also be removed because trim applies at both ends.
D:Given the specific operands supplied to the Terraform expression trim("...prod...", "."), leading periods must also be removed because trim applies at both ends.
Question 1169
A Terraform 1.12 configuration evaluates length(concat(["us"], reverse(["west", "east"]))). Which result follows from the expression as written?
- 6
- 3
- 4
- 2
Explanation
Correct Answer
B:For the specific expression length(concat(["us"], reverse(["west", "east"]))), First, reverse reorders the right-hand list before concat appends it; that produces exactly 3 elements; The outer length call counts those resulting elements rather than the original textual arguments.
Incorrect Answers
A:In the calculation length(concat(["us"], reverse(["west", "east"]))), 6 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(concat(["us"], reverse(["west", "east"]))), this counts one element beyond the 3 values produced by the inner expression; the inner stage produces ["us", "east", "west"] before the outer operation is applied.
D:For the concrete expression length(concat(["us"], reverse(["west", "east"]))), this drops one legitimate list element; the inner operation returns 3 values; the inner stage produces ["us", "east", "west"] before the outer operation is applied.
Question 1170
A Terraform 1.12 configuration evaluates join("/", concat(["us"], reverse(["west", "east"]))). Which result follows from the expression as written?
- "west/east/us"
- "us/east/west/west"
- "us/east/west"
- "useastwest"
Explanation
Correct Answer
C:For the specific expression join("/", concat(["us"], reverse(["west", "east"]))), First, reverse reorders the right-hand list before concat appends it; The outer join uses a slash only between consecutive list members and preserves their computed order.
Incorrect Answers
A:For the concrete expression join("/", concat(["us"], reverse(["west", "east"]))), this reverses the members even though join preserves the order returned by the inner expression; the inner stage produces ["us", "east", "west"] before the outer operation is applied.
B:For the concrete expression join("/", concat(["us"], reverse(["west", "east"]))), join must not repeat the last item after the list has been joined; the inner stage produces ["us", "east", "west"] before the outer operation is applied.
D:For the concrete expression join("/", concat(["us"], reverse(["west", "east"]))), this omits the slash delimiters requested by join; the inner stage produces ["us", "east", "west"] before the outer operation is applied.