INF-7036: support nested remote_var structures and bracket notation - #172
Open
rmaynardap wants to merge 1 commit into
Open
INF-7036: support nested remote_var structures and bracket notation#172rmaynardap wants to merge 1 commit into
rmaynardap wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends remote_vars to support nested structures (dicts/lists) and bracket/dot notation paths, enabling more flexible Terraform remote state references throughout generated locals and hook environment variables.
Changes:
- Introduces
tfworker/util/remote_vars.pyfor parsing/validation helpers and remote state extraction. - Updates locals generation and hook env population to handle nested
remote_varsvia recursive HCL generation and HCL2 parsing with regex fallback. - Improves S3 backend initialization error reporting for common AWS authentication failures; adds comprehensive tests and routine dependency lockfile updates.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tfworker/util/remote_vars.py | New helpers for parsing remote var references, generating TF refs, and extracting state names recursively. |
| tfworker/util/hooks.py | Adds HCL2-based locals parsing and recursive resolution of remote state references; adds env var size warnings. |
| tfworker/definitions/prepare.py | Generates nested HCL for remote_vars values and extracts remotes recursively. |
| tfworker/definitions/model.py | Expands remote_vars schema type to allow dict/list structures. |
| tfworker/backends/s3.py | Wraps common AWS auth failures into clearer BackendError messages. |
| tests/util/test_util_remote_vars.py | Unit tests for the new remote_vars parsing/extraction/validation helpers. |
| tests/util/test_util_hooks.py | Tests nested locals resolution, HCL2 fallback behavior, and env var size warnings. |
| tests/definitions/test_definitions_prepare_extra.py | Tests locals generation and remote extraction with nested remote_vars structures. |
| tests/backends/test_backends_s3.py | Tests new S3 auth error handling paths. |
| poetry.lock | Routine minor dependency version bumps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+488
to
+494
| else: | ||
| # Return specific output value | ||
| if output_key not in outputs: | ||
| raise HookError( | ||
| f"Output '{output_key}' not found in state '{state}'" | ||
| ) | ||
| return outputs[output_key].get("value") |
Comment on lines
+98
to
+100
| # Generate Terraform HCL for the value (handles str/dict/list) | ||
| tf_value = self._generate_tf_value(v, indent=1) | ||
| tflocals.write(f" {k} = {tf_value}\n") |
| lines = ["{"] | ||
| for key, val in value.items(): | ||
| nested_value = self._generate_tf_value(val, indent + 1) | ||
| lines.append(f'{" " * (indent + 1)}"{key}" = {nested_value}') |
rmaynardap
force-pushed
the
rm/INF-7036/allow_building_remote_var_types
branch
from
June 25, 2026 20:26
4ae9f5c to
07b12a2
Compare
Add support for nested structures (dicts/lists) in remote_vars configuration,
enabling more flexible Terraform remote state references.
Key changes:
- New tfworker/util/remote_vars.py module for parsing/validation
- Support nested keys: state.outputs.key.nested["item"]
- Generate proper HCL for dict/list structures in definitions
- Recursively resolve nested remote state values in hooks
- Add HCL2 parsing with regex fallback for backwards compatibility
- Check environment variable sizes and warn about shell limits
Additional improvements:
- Better AWS authentication error handling in S3 backend
(TokenRetrievalError, NoCredentialsError, PartialCredentialsError)
- Comprehensive test coverage (126 tests, parameterized for maintainability)
This allows configurations like:
```yaml
remote_vars:
kubernetes_clusters:
prod: clusters.outputs.items["prod-cluster"]
vpcs:
platform: network.outputs
```
rmaynardap
force-pushed
the
rm/INF-7036/allow_building_remote_var_types
branch
from
June 25, 2026 21:08
07b12a2 to
a39a625
Compare
ahay-8am
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for nested structures (dicts/lists) in remote_vars configuration, enabling more flexible Terraform remote state references.
Note to reviewers: This diff is fairly large, but a significant amount of it is the lockfile dependency changes (routine minor version updates to libraries), and tests, which provide comprehensive coverage and include edge cases.
Key changes:
Additional improvements:
This allows configurations like: