-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarify documentation, add usage & example output sections
- Loading branch information
1 parent
3e976d9
commit 814130a
Showing
1 changed file
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,72 @@ | ||
--- | ||
page_title: 'Command: modules' | ||
description: >- | ||
The terraform modules command prints information about all the declared | ||
The terraform modules command prints source and version data about all declared | ||
modules in Terraform configuration. | ||
--- | ||
|
||
# Command: modules | ||
|
||
The `terraform modules` command provides a holistic view of all Terraform | ||
modules and their resolved versions that have been declared in Terraform | ||
configuration for the current working directory. | ||
modules declared in Terraform configuration for the current working directory. | ||
This can be useful for auditing or policy purposes on module consumption. The | ||
output will include a list of each declared module's key, source and version. | ||
|
||
-> `terraform modules` requires **Terraform v1.10.0 or later**. | ||
|
||
## Usage | ||
|
||
Usage: `terraform modules -json` | ||
Usage: `terraform modules [options]` | ||
|
||
The following flags are available: | ||
|
||
- `-json` - Displays the module declarations in a machine-readable, JSON format. | ||
|
||
Please note that, at this time, the `-json` flag is a _required_ option. In future releases, this command will be extended to allow for additional options. | ||
|
||
The output includes a `format_version` key, which as of Terraform 1.10.0 has | ||
value `"1.0"`. The semantics of this version are: | ||
|
||
- We will increment the minor version, e.g. `"1.1"`, for backward-compatible | ||
changes or additions. Ignore any object properties with unrecognized names to | ||
remain forward-compatible with future minor versions. | ||
- We will increment the major version, e.g. `"2.0"`, for changes that are not | ||
backward-compatible. Reject any input which reports an unsupported major | ||
version. | ||
|
||
We will introduce new major versions only within the bounds of | ||
[the Terraform 1.0 Compatibility Promises](/terraform/language/v1-compatibility-promises). | ||
|
||
## Output Format | ||
|
||
The following section describes the JSON output format by example, using a pseudo-JSON notation. | ||
|
||
```javascript | ||
{ | ||
"format_version": "1.0", | ||
"modules": [ | ||
{ | ||
"key": "my_local_module", | ||
"source": "./path/to/local/module", | ||
"version": "" | ||
}, | ||
{ | ||
"key": "my_private_registry_module", | ||
"source": "app.terraform.io/hashicorp/label/null", | ||
"version": "1.0.0" | ||
}, | ||
{ | ||
"key": "my_public_registry_module", | ||
"source": "terraform-aws-modules/iam/aws", | ||
"version": "5.47.1" | ||
}, | ||
{ | ||
"key": "my_remote_module", | ||
"source": "https://example.com/vpc-module.zip", | ||
"version": "" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
|