Loading...
Loading...
# Terraform validate fails with "Missing required argument" after upgrading to v1.15.0 ### Terraform Version ```shell Terraform v1.15.0 ``` ### Terraform Configuration Files ### terraform/manifests/backend.tf ``` terraform { backend "azurerm" {} } ``` ### environments/stg/backend.tf (passed via -backend-config) ``` resource_group_name = "my-rg" storage_account_name = "mystorageaccount" container_name = "my-container" key = "stg.tfstate" ``` ### Debug Output https://gist.github.com/sivanesh-dsp/ee2e69ea67210ead2de282579d916a6b ### Expected Behavior `terraform validate` should pass, recognizing that backend arguments can be supplied via `-backend-config` during init (partial configuration). ### Actual Behavior ``` Error: Missing required argument on backend.tf line 2, in terraform: 2: backend "azurerm" {} The argument "storage_account_name" is required, but no definition was found. Error: Missing required argument on backend.tf line 2, in terraform: 2: backend "azurerm" {} The argument "key" is required, but no definition was found. Error: Missing required argument on backend.tf line 2, in terraform: 2: backend "azurerm" {} The argument "container_name" is required, but no definition was found. ``` ### Steps to Reproduce 1. Define a backend with an empty block: ``` terraform { backend "azurerm" {} } ``` 2. Initialize with a partial config file: ``` terraform init -backend-config=../environments/stg/backend.tf ``` whereas `backend.tf` contains: ``` resource_group_name = "my-rg" storage_account_name = "mystorageaccount" container_name = "my-container" key = "stg.tfstate" ``` 3. Run validate: ``` terraform validate ``` ### Additional Context - `terraform init` succeeds and correctly merges the backend config. - `terraform plan` works fine after successful init. - Only `validate` is affected since it checks the static block without considering the merged backend state. - The workaround is to add empty string placeholders in the backend block, which defeats the purpose of partial configuration. ### References - [#38021](https://github.com/hashicorp/terraform/pull/38021) (the PR that introduced backend validation in validate) - [Partial Configuration docs](https://developer.hashicorp.com/terraform/language/backend#partial-configuration) ### Generative AI / LLM assisted development? _No response_
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.