fix: compute recipe context before terraform get to satisfy required argument validation#11792
fix: compute recipe context before terraform get to satisfy required argument validation#11792Copilot wants to merge 2 commits into
Conversation
…argument validation Terraform 1.14.9 validates required module arguments during `terraform get`. The upstream kubernetes-redis module requires a `context` argument, but it was only being added AFTER the download step. This moves the recipe context computation to BEFORE the download, ensuring required arguments are present when terraform validates during module download. After download and inspection, if the module does not declare a context variable, it is removed from the config to avoid 'unexpected argument' errors during init/apply. Agent-Logs-Url: https://github.com/radius-project/radius/sessions/da1fcb4d-e5e9-4735-822f-cc86911c2544 Co-authored-by: sylvainsf <540991+sylvainsf@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11792 +/- ##
==========================================
- Coverage 51.40% 51.39% -0.02%
==========================================
Files 699 699
Lines 44036 44048 +12
==========================================
- Hits 22638 22637 -1
- Misses 19244 19256 +12
- Partials 2154 2155 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| delete(mod, recipecontext.RecipeContextParamKey) | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
What if users were using the context to pass some information? I am a bit doubtful if this could break their recipe. But we were also talking about the context being not important since we now pass the connected resource's properties. We just have not documented the change / made sure our recipes dont still use context + @kachawla for inputs.
Description
Terraform 1.14.9 validates required module arguments during
terraform get. The upstreamterraform-private-modules//kubernetes-redismodule requires acontextvariable, but the Terraform driver was only injecting it AFTER the download step — causingterraform getto fail withMissing required argument: context.Fix: Compute and include the recipe context in the module config before
terraform get. After download and inspection, remove it if the module doesn't actually declare the variable (to avoid "unexpected argument" errors during init/apply).pkg/recipes/terraform/execute.go— ReordergenerateConfigandGetRecipeMetadatato add context before save/download. After inspection, callRemoveRecipeContextif module lacks the variable.pkg/recipes/terraform/config/config.go— AddRemoveRecipeContext(moduleName)method.pkg/recipes/terraform/execute_test.go— UpdateTest_GetTerraformConfig_InvalidDirectorysincegetTerraformConfigno longer saves to disk.pkg/recipes/terraform/config/config_test.go— AddTest_RemoveRecipeContext.Type of change
Contributor checklist
Please verify that the PR meets the following requirements, where applicable: