Skip to content

Terraform recipe deployment fails with "Missing required argument" for context variable in Radius v0.57 #11867

Closed

Description

@willtsai

Bug Report

Description

Terraform recipe deployment fails during terraform get (module download) with Missing required argument for the context variable. This is a regression — the same recipe and configuration worked on a previous Radius version.

Steps to Reproduce

  1. Register a Terraform recipe that declares a required context variable (no default value):
variable "context" {
  description = "This variable contains Radius recipe context."
  type        = any
}
  1. Deploy a resource that uses this recipe (e.g. Radius.Resources/aiModels)

  2. Deployment fails with:

Error: Missing required argument

  on main.tf.json line 8, in module.default:
   8:     }

The argument "context" is required, but no definition was found.

Root Cause Analysis

The Terraform recipe execution flow in pkg/recipes/terraform/execute.go (generateConfig) is:

  1. getTerraformConfig — writes main.tf.json with only the module source and explicit parameters (e.g. location, resource_group_name). The context variable is NOT included yet.
  2. downloadAndInspect → calls tf.Get(ctx) (terraform get) to download the module
  3. inspectModule — checks if ContextVarExists in the downloaded module
  4. AddRecipeContext — injects context into the config
  5. tfConfig.Save — re-saves the config with context included
  6. initAndApply — runs terraform init + terraform apply

The problem is that Terraform v1.15.2 (bundled in the dynamic-rp:0.57 container) now performs strict validation of required module arguments during terraform get (step 2). Since context has not been added to main.tf.json yet at that point, validation fails.

In prior Radius versions, the bundled Terraform binary did not validate required arguments during terraform get, so the 2-phase approach (download first, inject context later) worked fine.

Environment

  • Radius version: v0.57.0
  • Terraform version (inside dynamic-rp container): v1.15.2
  • Resource type: Radius.Resources/aiModels@2025-07-14-preview
  • Recipe source: git::https://github.com/reshrahim/todoapp-ai.git//recipes/azure-openai

Expected Behavior

Terraform recipe deployment should succeed. The context variable should either be:

  • Pre-populated with a placeholder value in main.tf.json before terraform get, or
  • The terraform get step should be performed without module argument validation

Actual Behavior

terraform get fails with Missing required argument because context is not yet present in main.tf.json.

Workaround

Add default = {} to the context variable in the recipe:

variable "context" {
  description = "This variable contains Radius recipe context."
  type        = any
  default     = {}
}

This allows terraform get to succeed without the value, and Radius injects the real value before terraform apply.

Relevant Code

Activity

  1. added
    bugSomething is broken or not working as expected
    on May 12, 2026
  2. radius-triage commented on May 12, 2026

    @radius-triage

    👋 @willtsai Thanks for filing this bug report.

    A project maintainer will review this report and get back to you soon. If you'd like immediate help troubleshooting, please visit our Discord server.

    For more information on our triage process please visit our triage overview

  3. willtsai commented on May 13, 2026

    @willtsai
    ContributorAuthor

    this is fixed as a part of #11779 which was patched into v0.57.1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or not working as expected

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions