
OPERATIONAL DEFECT DATABASE
...


...

### Terraform Version ```shell Terraform 1.15.0-dev ``` ### Terraform Configuration Files ```terraform terraform { required_providers { aws = { source = "hashicorp/aws" } } backend "local" {} } ``` ### Debug Output N/A ### Expected Behavior When running `terraform init -json` using the config above in an empty working directory, all of the command's output should be in JSON format. ### Actual Behavior One of the messages logged to the terminal isn't in JSON format: ``` {"@level":"info","@message":"Terraform 1.15.0-dev","@module":"terraform.ui","@timestamp":"2025-11-17T17:17:58.540604Z","terraform":"1.15.0-dev","type":"version","ui":"1.2"} {"@level":"info","@message":"Initializing provider plugins found in the configuration...","@module":"terraform.ui","@timestamp":"2025-11-17T17:18:04.314Z","message_code":"initializing_provider_plugin_from_config_message","type":"init_output"} {"@level":"info","@message":"hashicorp/aws: Finding latest version...","@module":"terraform.ui","@timestamp":"2025-11-17T17:18:04.314594Z","type":"log"} {"@level":"info","@message":"Installing provider version: hashicorp/aws v6.21.0...","@module":"terraform.ui","@timestamp":"2025-11-17T17:18:04.784659Z","type":"log"} {"@level":"info","@message":"Installed provider version: hashicorp/aws v6.21.0 (signed by HashiCorp)","@module":"terraform.ui","@timestamp":"2025-11-17T17:18:26.345919Z","type":"log"} {"@level":"info","@message":"Initializing the backend...","@module":"terraform.ui","@timestamp":"2025-11-17T17:18:52.256Z","message_code":"initializing_backend_message","type":"init_output"} Successfully configured the backend "local"! Terraform will automatically use this backend unless the backend configuration changes. {"@level":"info","@message":"Terraform has created a lock file .terraform.lock.hcl to record the provider\nselections it made above. Include this file in your version control repository\nso that Terraform can guarantee to make the same selections by default when\nyou run \"terraform init\" in the future.","@module":"terraform.ui","@timestamp":"2025-11-17T17:19:06.698Z","message_code":"lock_info","type":"init_output"} {"@level":"info","@message":"Terraform has been successfully initialized!","@module":"terraform.ui","@timestamp":"2025-11-17T17:19:09.915Z","message_code":"output_init_success_message","type":"init_output"} {"@level":"info","@message":"You may now begin working with Terraform. Try running \"terraform plan\" to see\nany changes that are required for your infrastructure. All Terraform commands\nshould now work.\n\nIf you ever set or change modules or backend configuration for Terraform,\nrerun this command to reinitialize your working directory. If you forget, other\ncommands will detect it and remind you to do so if necessary.","@module":"terraform.ui","@timestamp":"2025-11-17T17:19:10.553Z","message_code":"output_init_success_cli_message","type":"init_output"} ``` >Successfully configured the backend "local"! Terraform will automatically use this backend unless the backend configuration changes. ### Steps to Reproduce 1. `terraform init -json` ### Additional Context The non-JSON message originates from: https://github.com/hashicorp/terraform/blob/1dd8e60f158cb2aec3efd62408bbe81f2d765fd6/internal/command/meta_backend.go#L1355-L1357 I think that all parts of `init`-related code that use the `Ui` abstraction are unable to output logs in JSON format, as the `View` abstraction is needed for that. This means running init in other situations (e.g. migrating when unsetting `backend` from the config) would have the same issue with JSON output. ### References See also: * https://github.com/hashicorp/terraform/issues/37439 ### Generative AI / LLM assisted development? N/A
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.