Skip to content

terraform: Document JSON output from init #656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions content/terraform/v1.10.x/docs/cli/commands/init.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ The following options apply to all of (or several of) the initialization steps:
* `-upgrade` Opt to upgrade modules and plugins as part of their respective
installation steps. See the sections below for more details.

* `-json` - Enables the [machine readable JSON UI][machine-readable-ui] output.

[machine-readable-ui]: /terraform/internals/machine-readable-ui

## Copy a Source Module

By default, `terraform init` assumes that the working directory already
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,54 @@ The following message types are supported:
- `log`: unstructured human-readable log lines
- `diagnostic`: diagnostic warning or error messages; [see the `terraform validate` docs for more details on the format](/terraform/cli/commands/validate#json)

### Init Messages

Messages coming from `init` command's JSON output may have `type` `init_output` or `log` (as documented above).
Messages with `init_output` type have an additional `message_code` documented below.

#### Example Output

```json
{"@level":"info","@message":"Terraform 1.9.0","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:15.919212+02:00","terraform":"1.9.0","type":"version","ui":"1.2"}
{"@level":"info","@message":"Initializing the backend...","@module":"terraform.ui","@timestamp":"2025-08-11T13:09:15Z","message_code":"initializing_backend_message","type":"init_output"}
{"@level":"info","@message":"Initializing provider plugins...","@module":"terraform.ui","@timestamp":"2025-08-11T13:09:15Z","message_code":"initializing_provider_plugin_message","type":"init_output"}
{"@level":"info","@message":"Finding matching versions for provider: hashicorp/aws, version_constraint: \"~\u003e 6.8\"","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:15.921436+02:00","type":"log"}
{"@level":"info","@message":"hashicorp/random: Reusing previous version from the dependency lock file","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:16.874024+02:00","type":"log"}
{"@level":"info","@message":"Installing provider version: hashicorp/aws v6.8.0...","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:18.827459+02:00","type":"log"}
{"@level":"info","@message":"Installed provider version: hashicorp/aws v6.8.0 (signed by HashiCorp)","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:35.414989+02:00","type":"log"}
{"@level":"info","@message":"Installing provider version: hashicorp/random v3.7.2...","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:36.363085+02:00","type":"log"}
{"@level":"info","@message":"Installed provider version: hashicorp/random v3.7.2 (signed by HashiCorp)","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:42.258989+02:00","type":"log"}
{"@level":"info","@message":"Terraform has made some changes to the provider dependency selections recorded\nin the .terraform.lock.hcl file. Review those changes and commit them to your\nversion control system if they represent changes you intended to make.","@module":"terraform.ui","@timestamp":"2025-08-11T13:09:42Z","message_code":"dependencies_lock_changes_info","type":"init_output"}
{"@level":"info","@message":"Terraform has been successfully initialized!","@module":"terraform.ui","@timestamp":"2025-08-11T13:09:42Z","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-08-11T13:09:42Z","message_code":"output_init_success_cli_message","type":"init_output"}
```

#### General

- `initializing_terraform_cloud_message`: indicates progress during initialisation of HCP Terraform (`cloud` backend)
- `initializing_backend_message`: indicates progress during initialisation of a backend
- `empty_message`: describes an empty message; equivalent to a new line aiding formatting in terminal output
- `output_init_empty_message`: indicates that an _empty_ directory was successfully initialised
- `output_init_success_message`: indicates that a [not empty] directory was successfully initialised via CLI
- `output_init_success_cloud_message`: indicates that a [not empty] directory was successfully initialised via HCP Terraform
- `output_init_success_cli_message`: instructions for next steps after a directory was successfully initialised via CLI
- `output_init_success_cli_cloud_message`: instructions for next steps after a directory was successfully initialised via HCP Terraform

#### Provider Installation

- `initializing_provider_plugin_message`: indicates progress during installation of providers
- `provider_already_installed_message`: indicates a provider that is already installed during installation
- `built_in_provider_available_message`: indicates a built-in provider in use during installation
- `installing_provider_message`: indicates that a provider is being installed (from a remote location)
- `lock_info`: describes that a new lock file was created for installed providers
- `dependencies_lock_changes_info`: describes that the lock file was changed (e.g. as a result of provider installation or upgrade)

#### Module Installation

- `copying_configuration_message`: indicates progress during module contents copying when `-from-module` flag is used
- `upgrading_modules_message`: indicates progress during module upgrading when `-upgrade` flag is used
- `initializing_modules_message`: indicates progress during installation of modules

### Operation Results

- `resource_drift`: describes a detected change to a single resource made outside of Terraform
Expand Down
4 changes: 4 additions & 0 deletions content/terraform/v1.11.x/docs/cli/commands/init.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ The following options apply to all of (or several of) the initialization steps:
* `-upgrade` Opt to upgrade modules and plugins as part of their respective
installation steps. See the sections below for more details.

* `-json` - Enables the [machine readable JSON UI][machine-readable-ui] output.

[machine-readable-ui]: /terraform/internals/machine-readable-ui

## Copy a Source Module

By default, `terraform init` assumes that the working directory already
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,54 @@ The following message types are supported:
- `log`: unstructured human-readable log lines
- `diagnostic`: diagnostic warning or error messages; [see the `terraform validate` docs for more details on the format](/terraform/cli/commands/validate#json)

### Init Messages

Messages coming from `init` command's JSON output may have `type` `init_output` or `log` (as documented above).
Messages with `init_output` type have an additional `message_code` documented below.

#### Example Output

```json
{"@level":"info","@message":"Terraform 1.9.0","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:15.919212+02:00","terraform":"1.9.0","type":"version","ui":"1.2"}
{"@level":"info","@message":"Initializing the backend...","@module":"terraform.ui","@timestamp":"2025-08-11T13:09:15Z","message_code":"initializing_backend_message","type":"init_output"}
{"@level":"info","@message":"Initializing provider plugins...","@module":"terraform.ui","@timestamp":"2025-08-11T13:09:15Z","message_code":"initializing_provider_plugin_message","type":"init_output"}
{"@level":"info","@message":"Finding matching versions for provider: hashicorp/aws, version_constraint: \"~\u003e 6.8\"","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:15.921436+02:00","type":"log"}
{"@level":"info","@message":"hashicorp/random: Reusing previous version from the dependency lock file","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:16.874024+02:00","type":"log"}
{"@level":"info","@message":"Installing provider version: hashicorp/aws v6.8.0...","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:18.827459+02:00","type":"log"}
{"@level":"info","@message":"Installed provider version: hashicorp/aws v6.8.0 (signed by HashiCorp)","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:35.414989+02:00","type":"log"}
{"@level":"info","@message":"Installing provider version: hashicorp/random v3.7.2...","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:36.363085+02:00","type":"log"}
{"@level":"info","@message":"Installed provider version: hashicorp/random v3.7.2 (signed by HashiCorp)","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:42.258989+02:00","type":"log"}
{"@level":"info","@message":"Terraform has made some changes to the provider dependency selections recorded\nin the .terraform.lock.hcl file. Review those changes and commit them to your\nversion control system if they represent changes you intended to make.","@module":"terraform.ui","@timestamp":"2025-08-11T13:09:42Z","message_code":"dependencies_lock_changes_info","type":"init_output"}
{"@level":"info","@message":"Terraform has been successfully initialized!","@module":"terraform.ui","@timestamp":"2025-08-11T13:09:42Z","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-08-11T13:09:42Z","message_code":"output_init_success_cli_message","type":"init_output"}
```

#### General

- `initializing_terraform_cloud_message`: indicates progress during initialisation of HCP Terraform (`cloud` backend)
- `initializing_backend_message`: indicates progress during initialisation of a backend
- `empty_message`: describes an empty message; equivalent to a new line aiding formatting in terminal output
- `output_init_empty_message`: indicates that an _empty_ directory was successfully initialised
- `output_init_success_message`: indicates that a [not empty] directory was successfully initialised via CLI
- `output_init_success_cloud_message`: indicates that a [not empty] directory was successfully initialised via HCP Terraform
- `output_init_success_cli_message`: instructions for next steps after a directory was successfully initialised via CLI
- `output_init_success_cli_cloud_message`: instructions for next steps after a directory was successfully initialised via HCP Terraform

#### Provider Installation

- `initializing_provider_plugin_message`: indicates progress during installation of providers
- `provider_already_installed_message`: indicates a provider that is already installed during installation
- `built_in_provider_available_message`: indicates a built-in provider in use during installation
- `installing_provider_message`: indicates that a provider is being installed (from a remote location)
- `lock_info`: describes that a new lock file was created for installed providers
- `dependencies_lock_changes_info`: describes that the lock file was changed (e.g. as a result of provider installation or upgrade)

#### Module Installation

- `copying_configuration_message`: indicates progress during module contents copying when `-from-module` flag is used
- `upgrading_modules_message`: indicates progress during module upgrading when `-upgrade` flag is used
- `initializing_modules_message`: indicates progress during installation of modules

### Operation Results

- `resource_drift`: describes a detected change to a single resource made outside of Terraform
Expand Down
4 changes: 4 additions & 0 deletions content/terraform/v1.12.x/docs/cli/commands/init.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ The following options apply to all of (or several of) the initialization steps:
* `-upgrade` Opt to upgrade modules and plugins as part of their respective
installation steps. See the sections below for more details.

* `-json` - Enables the [machine readable JSON UI][machine-readable-ui] output.

[machine-readable-ui]: /terraform/internals/machine-readable-ui

## Copy a Source Module

By default, `terraform init` assumes that the working directory already
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,54 @@ The following message types are supported:
- `log`: unstructured human-readable log lines
- `diagnostic`: diagnostic warning or error messages; [see the `terraform validate` docs for more details on the format](/terraform/cli/commands/validate#json)

### Init Messages

Messages coming from `init` command's JSON output may have `type` `init_output` or `log` (as documented above).
Messages with `init_output` type have an additional `message_code` documented below.

#### Example Output

```json
{"@level":"info","@message":"Terraform 1.9.0","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:15.919212+02:00","terraform":"1.9.0","type":"version","ui":"1.2"}
{"@level":"info","@message":"Initializing the backend...","@module":"terraform.ui","@timestamp":"2025-08-11T13:09:15Z","message_code":"initializing_backend_message","type":"init_output"}
{"@level":"info","@message":"Initializing provider plugins...","@module":"terraform.ui","@timestamp":"2025-08-11T13:09:15Z","message_code":"initializing_provider_plugin_message","type":"init_output"}
{"@level":"info","@message":"Finding matching versions for provider: hashicorp/aws, version_constraint: \"~\u003e 6.8\"","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:15.921436+02:00","type":"log"}
{"@level":"info","@message":"hashicorp/random: Reusing previous version from the dependency lock file","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:16.874024+02:00","type":"log"}
{"@level":"info","@message":"Installing provider version: hashicorp/aws v6.8.0...","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:18.827459+02:00","type":"log"}
{"@level":"info","@message":"Installed provider version: hashicorp/aws v6.8.0 (signed by HashiCorp)","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:35.414989+02:00","type":"log"}
{"@level":"info","@message":"Installing provider version: hashicorp/random v3.7.2...","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:36.363085+02:00","type":"log"}
{"@level":"info","@message":"Installed provider version: hashicorp/random v3.7.2 (signed by HashiCorp)","@module":"terraform.ui","@timestamp":"2025-08-11T15:09:42.258989+02:00","type":"log"}
{"@level":"info","@message":"Terraform has made some changes to the provider dependency selections recorded\nin the .terraform.lock.hcl file. Review those changes and commit them to your\nversion control system if they represent changes you intended to make.","@module":"terraform.ui","@timestamp":"2025-08-11T13:09:42Z","message_code":"dependencies_lock_changes_info","type":"init_output"}
{"@level":"info","@message":"Terraform has been successfully initialized!","@module":"terraform.ui","@timestamp":"2025-08-11T13:09:42Z","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-08-11T13:09:42Z","message_code":"output_init_success_cli_message","type":"init_output"}
```

#### General

- `initializing_terraform_cloud_message`: indicates progress during initialisation of HCP Terraform (`cloud` backend)
- `initializing_backend_message`: indicates progress during initialisation of a backend
- `empty_message`: describes an empty message; equivalent to a new line aiding formatting in terminal output
- `output_init_empty_message`: indicates that an _empty_ directory was successfully initialised
- `output_init_success_message`: indicates that a [not empty] directory was successfully initialised via CLI
- `output_init_success_cloud_message`: indicates that a [not empty] directory was successfully initialised via HCP Terraform
- `output_init_success_cli_message`: instructions for next steps after a directory was successfully initialised via CLI
- `output_init_success_cli_cloud_message`: instructions for next steps after a directory was successfully initialised via HCP Terraform

#### Provider Installation

- `initializing_provider_plugin_message`: indicates progress during installation of providers
- `provider_already_installed_message`: indicates a provider that is already installed during installation
- `built_in_provider_available_message`: indicates a built-in provider in use during installation
- `installing_provider_message`: indicates that a provider is being installed (from a remote location)
- `lock_info`: describes that a new lock file was created for installed providers
- `dependencies_lock_changes_info`: describes that the lock file was changed (e.g. as a result of provider installation or upgrade)

#### Module Installation

- `copying_configuration_message`: indicates progress during module contents copying when `-from-module` flag is used
- `upgrading_modules_message`: indicates progress during module upgrading when `-upgrade` flag is used
- `initializing_modules_message`: indicates progress during installation of modules

### Operation Results

- `resource_drift`: describes a detected change to a single resource made outside of Terraform
Expand Down
4 changes: 4 additions & 0 deletions content/terraform/v1.13.x (rc)/docs/cli/commands/init.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ The following options apply to all of (or several of) the initialization steps:
* `-upgrade` Opt to upgrade modules and plugins as part of their respective
installation steps. See the sections below for more details.

* `-json` - Enables the [machine readable JSON UI][machine-readable-ui] output.

[machine-readable-ui]: /terraform/internals/machine-readable-ui

## Copy a Source Module

By default, `terraform init` assumes that the working directory already
Expand Down
Loading
Loading