Skip to content

Support Opentofu iterated provider#408

Open
dene14 wants to merge 3 commits intotranscend-io:masterfrom
dene14:opentofu_iterated_provider
Open

Support Opentofu iterated provider#408
dene14 wants to merge 3 commits intotranscend-io:masterfrom
dene14:opentofu_iterated_provider

Conversation

@dene14
Copy link

@dene14 dene14 commented Oct 15, 2025

Pull Request

The fix allows terragrunt-atlantis-config to work with OpenTofu's iterated provider definitions, enabling multi-region resource provisioning as requested.

Related Github Issues

407

Description

Solution includes:

  1. New OpenTofu-aware parsing module (cmd/parse_opentofu.go):
    • parseOpenTofuProviderRef() - Handles OpenTofu provider syntax with index operations
    • parseTerraformLocalModuleSourceOpenTofu() - Fallback parser when standard parsing fails
    • isOpenTofuProviderSyntax() - Detects OpenTofu provider patterns
  2. Modified existing parsing logic (cmd/parse_tf.go):
    • Updated parseTerraformLocalModuleSource() to try OpenTofu-aware parsing first
    • Falls back to standard parsing if OpenTofu parsing fails
    • Maintains backward compatibility
  3. Test cases and validation:
    • Created test example with OpenTofu provider syntax
    • Added TestOpenTofuProviderSyntax test case
    • Generated golden test file for validation
    • Updated affected golden files

Key Features of the Fix

  • Backward Compatible: Existing Terraform configurations continue to work unchanged
  • OpenTofu Support: Now handles syntax like aws.by_region[each.key]
  • Graceful Fallback: If OpenTofu parsing fails, falls back to standard parsing
  • Comprehensive Testing: Includes test cases and validation

Legend for modified files

cmd/parse_opentofu.go - New OpenTofu parsing module
cmd/parse_tf.go - Updated to use OpenTofu-aware parsing
cmd/generate_test.go - Added test case
cmd/golden/opentofu_provider_syntax.yaml - Golden test file
cmd/golden/envhcl_allchilds.yaml - Updated to include new test case

Test Results

✅ The OpenTofu provider syntax now works without errors
✅ All existing functionality remains intact
✅ Test cases pass successfully

Security Implications

  • [none]

System Availability

  • [none]

@dene14
Copy link
Author

dene14 commented Oct 15, 2025

@dmattia can we get this reviewed/merged?

@dene14
Copy link
Author

dene14 commented Oct 15, 2025

@dennislapchenko just in case also ping you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant