Question 1070
A Terraform 1.12 configuration evaluates join("/", concat(["app", "db"], ["cache"])). Which result follows from the expression as written?
- "cache/db/app"
- "app/db/cache/cache"
- "app/db/cache"
- "appdbcache"
Explanation
Correct Answer
C:For the specific expression join("/", concat(["app", "db"], ["cache"])), First, concat appends the second list after the first; 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(["app", "db"], ["cache"])), this reverses the members even though join preserves the order returned by the inner expression; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
B:For the concrete expression join("/", concat(["app", "db"], ["cache"])), join must not repeat the last item after the list has been joined; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
D:For the concrete expression join("/", concat(["app", "db"], ["cache"])), this omits the slash delimiters requested by join; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
Question 1071
Before adopting Formatting preserved semantics to change whitespace and presentation without intending resource changes, which statement sets an accurate boundary?
- The check does not fix configuration automatically.
- Operators should still review unexpected source diffs from any automated formatter.
- Formatting does not validate external credentials or apply changes.
- A style diff is not an infrastructure change plan.
Explanation
Correct Answer
B:For Formatting preserved semantics in the task to change whitespace and presentation without intending resource changes, the important caution is: Operators should still review unexpected source diffs from any automated formatter. The reason this matters is its actual behavior: terraform fmt standardizes language presentation instead of performing infrastructure reconciliation.
Incorrect Answers
A:The proposed warning belongs to terraform fmt -check, which serves the different goal to fail a style gate without modifying source files, rather than to Formatting preserved semantics: terraform fmt -check tests whether files are already formatted and returns an exit status. The question concerns Formatting preserved semantics acting to change whitespace and presentation without intending resource changes, not a limit of terraform fmt -check.
C:The proposed warning belongs to terraform fmt command, which serves the different goal to rewrite Terraform configuration into its canonical layout, rather than to Formatting preserved semantics: terraform fmt formats Terraform language files consistently, including spacing and alignment. The question concerns Formatting preserved semantics acting to change whitespace and presentation without intending resource changes, not a limit of terraform fmt command.
D:The proposed warning belongs to terraform fmt -diff, which serves the different goal to display differences that canonical formatting would introduce, rather than to Formatting preserved semantics: terraform fmt -diff shows a style diff for files that need formatting. The question concerns Formatting preserved semantics acting to change whitespace and presentation without intending resource changes, not a limit of terraform fmt -diff.
Question 1072
A Terraform 1.12 configuration evaluates reverse(concat(["app", "db"], ["cache"])). Which result follows from the expression as written?
- ["cache", "db", "app"]
- ["app", "db", "cache"]
- ["app", "cache", "db"]
- ["db", "cache", "app"]
Explanation
Correct Answer
A:For the specific expression reverse(concat(["app", "db"], ["cache"])), First, concat appends the second list after the first; reverse then returns the exact opposite element order, without sorting or removing members.
Incorrect Answers
B:For the concrete expression reverse(concat(["app", "db"], ["cache"])), this leaves the inner result unchanged and skips the outer reverse call; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
C:For the concrete expression reverse(concat(["app", "db"], ["cache"])), alphabetic sorting is not the same as reversing the sequence produced by the inner expression; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
D:For the concrete expression reverse(concat(["app", "db"], ["cache"])), rotating the input left one position does not invert every position as reverse requires; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
Question 1073
A Terraform rollout has two separate requirements: first, change whitespace and presentation without intending resource changes; second, fail a style gate without modifying source files. Which assignment of mechanisms correctly handles both responsibilities?
- First use terraform fmt -check; then use Formatting preserved semantics.
- First use terraform fmt -recursive; then use terraform fmt -check.
- First use terraform fmt -diff; then use terraform fmt -recursive.
- First use Formatting preserved semantics; then use terraform fmt -check.
- First use Formatting preserved semantics; then use terraform fmt -diff.
Explanation
Correct Answer
D:The first requirement, to change whitespace and presentation without intending resource changes, is handled by Formatting preserved semantics: terraform fmt standardizes language presentation instead of performing infrastructure reconciliation. The second requirement, to fail a style gate without modifying source files, is handled by terraform fmt -check: terraform fmt -check tests whether files are already formatted and returns an exit status. Each of these mechanisms has a distinct responsibility.
Incorrect Answers
A:For the requested tasks to change whitespace and presentation without intending resource changes and fail a style gate without modifying source files, the first candidate terraform fmt -check addresses fail a style gate without modifying source files; the second candidate Formatting preserved semantics addresses change whitespace and presentation without intending resource changes. This mapping fails because the first mechanism primarily supports the task to fail a style gate without modifying source files and the second mechanism primarily supports the task to change whitespace and presentation without intending resource changes; the actual requirements are change whitespace and presentation without intending resource changes first and fail a style gate without modifying source files second.
B:For the requested tasks to change whitespace and presentation without intending resource changes and fail a style gate without modifying source files, the first candidate terraform fmt -recursive addresses format Terraform configurations in nested local directories; the second candidate terraform fmt -check addresses fail a style gate without modifying source files. This mapping fails because the first mechanism primarily supports the task to format Terraform configurations in nested local directories; the actual requirements are change whitespace and presentation without intending resource changes first and fail a style gate without modifying source files second.
C:For the requested tasks to change whitespace and presentation without intending resource changes and fail a style gate without modifying source files, the first candidate terraform fmt -diff addresses display differences that canonical formatting would introduce; the second candidate terraform fmt -recursive addresses format Terraform configurations in nested local directories. This mapping fails because the first mechanism primarily supports the task to display differences that canonical formatting would introduce and the second mechanism primarily supports the task to format Terraform configurations in nested local directories; the actual requirements are change whitespace and presentation without intending resource changes first and fail a style gate without modifying source files second.
E:For the requested tasks to change whitespace and presentation without intending resource changes and fail a style gate without modifying source files, the first candidate Formatting preserved semantics addresses change whitespace and presentation without intending resource changes; the second candidate terraform fmt -diff addresses display differences that canonical formatting would introduce. This mapping fails because the second mechanism primarily supports the task to display differences that canonical formatting would introduce; the actual requirements are change whitespace and presentation without intending resource changes first and fail a style gate without modifying source files second.
Question 1074
A Terraform 1.12 configuration evaluates sort(concat(["app", "db"], ["cache"])). Which result follows from the expression as written?
- ["app", "db", "cache"]
- ["app", "cache", "db", "db"]
- ["app", "cache", "db"]
- ["cache", "db", "app"]
Explanation
Correct Answer
C:For the specific expression sort(concat(["app", "db"], ["cache"])), First, concat appends the second list after the first; 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(concat(["app", "db"], ["cache"])), this retains the source order rather than explicitly sorting the result (unless it was already sorted); the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
B:The alternative changes the member count or order by injecting or dropping an entry; the particular expression sort(concat(["app", "db"], ["cache"])) neither makes that extra insertion nor drops the required entry.
D:For the concrete expression sort(concat(["app", "db"], ["cache"])), a reversal is not guaranteed to produce ascending lexical order; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
Question 1075
A Terraform 1.12 configuration evaluates element(concat(["app", "db"], ["cache"]), 4). Which result follows from the expression as written?
- "app"
- "cache"
- "index out of range"
- "db"
Explanation
Correct Answer
D:For the specific expression element(concat(["app", "db"], ["cache"]), 4), First, concat appends the second list after the first; 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(concat(["app", "db"], ["cache"]), 4), index wraparound lands at position one, not the first position of the inner list; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
B:For the concrete expression element(concat(["app", "db"], ["cache"]), 4), the final list member is not selected; the effective index is one; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
C:For the concrete expression element(concat(["app", "db"], ["cache"]), 4), element wraps a positive index instead of failing like ordinary square-bracket indexing; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
Question 1076
A Terraform 1.12 configuration evaluates slice(concat(["app", "db"], ["cache"]), 1, 3). Which result follows from the expression as written?
- ["db", "cache"]
- ["app", "db", "cache"]
- ["app", "db"]
- ["cache", "db"]
Explanation
Correct Answer
A:For the specific expression slice(concat(["app", "db"], ["cache"]), 1, 3), First, concat appends the second list after the first; 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(concat(["app", "db"], ["cache"]), 1, 3), this incorrectly keeps the first list member, although the slice begins at index one; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
C:For the concrete expression slice(concat(["app", "db"], ["cache"]), 1, 3), this takes an initial prefix rather than starting with the second entry; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
D:For the concrete expression slice(concat(["app", "db"], ["cache"]), 1, 3), slice preserves order rather than reversing the extracted portion; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
Question 1077
A Terraform 1.12 configuration evaluates format("primary=%s", element(concat(["app", "db"], ["cache"]), 0)). Which result follows from the expression as written?
- "secondary=app"
- "primary=app"
- "primary=db"
- "app"
Explanation
Correct Answer
B:For the specific expression format("primary=%s", element(concat(["app", "db"], ["cache"]), 0)), First, concat appends the second list after the first; 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(concat(["app", "db"], ["cache"]), 0)), the prefix is specified literally as primary= rather than secondary=; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
C:For the concrete expression format("primary=%s", element(concat(["app", "db"], ["cache"]), 0)), this uses the second list element; element at index zero selects the first value; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
D:For the concrete expression format("primary=%s", element(concat(["app", "db"], ["cache"]), 0)), the format string has a literal primary= prefix that must appear in the result; the inner stage produces ["app", "db", "cache"] before the outer operation is applied.
Question 1078
A Terraform 1.12 configuration evaluates length(sort(["west", "east", "central"])). Which result follows from the expression as written?
- 5
- 0
- 3
- 2
Explanation
Correct Answer
C:For the specific expression length(sort(["west", "east", "central"])), First, sort orders strings lexicographically; 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(sort(["west", "east", "central"])), the inner collection has 3 values, not 5; length counts the resulting collection only; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
B:For the concrete expression length(sort(["west", "east", "central"])), the inner expression is not empty: it produces 3 elements; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
D:For the concrete expression length(sort(["west", "east", "central"])), this drops one legitimate list element; the inner operation returns 3 values; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
Question 1079
A Terraform 1.12 configuration evaluates join("/", sort(["west", "east", "central"])). Which result follows from the expression as written?
- "centraleastwest"
- "west/east/central"
- "central/east/west/west"
- "central/east/west"
Explanation
Correct Answer
D:For the specific expression join("/", sort(["west", "east", "central"])), First, sort orders strings lexicographically; The outer join uses a slash only between consecutive list members and preserves their computed order.
Incorrect Answers
A:For the concrete expression join("/", sort(["west", "east", "central"])), this omits the slash delimiters requested by join; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
B:For the concrete expression join("/", sort(["west", "east", "central"])), this reverses the members even though join preserves the order returned by the inner expression; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
C:For the concrete expression join("/", sort(["west", "east", "central"])), join must not repeat the last item after the list has been joined; the inner stage produces ["central", "east", "west"] before the outer operation is applied.
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.