|
| 1 | +--- |
| 2 | +page_title: Functions Metadata |
| 3 | +description: >- |
| 4 | + The `terraform metadata functions` command prints signatures for all the |
| 5 | + functions available in the current Terraform version. |
| 6 | +--- |
| 7 | + |
| 8 | +# Functions Metadata |
| 9 | + |
| 10 | +The `terraform metadata functions` command is used to print signatures for the functions available in the current Terraform version. |
| 11 | + |
| 12 | +-> `terraform metadata functions` requires **Terraform v1.4 or later**. |
| 13 | + |
| 14 | +## Usage |
| 15 | + |
| 16 | +Usage: `terraform metadata functions [options]` |
| 17 | + |
| 18 | +The following flags are available: |
| 19 | + |
| 20 | +- `-json` - Displays the function signatures in a machine-readable, JSON format. |
| 21 | + |
| 22 | +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. |
| 23 | + |
| 24 | +The output includes a `format_version` key, which as of Terraform 1.4.0 has |
| 25 | +value `"1.0"`. The semantics of this version are: |
| 26 | + |
| 27 | +- We will increment the minor version, e.g. `"1.1"`, for backward-compatible |
| 28 | + changes or additions. Ignore any object properties with unrecognized names to |
| 29 | + remain forward-compatible with future minor versions. |
| 30 | +- We will increment the major version, e.g. `"2.0"`, for changes that are not |
| 31 | + backward-compatible. Reject any input which reports an unsupported major |
| 32 | + version. |
| 33 | + |
| 34 | +We will introduce new major versions only within the bounds of |
| 35 | +[the Terraform 1.0 Compatibility Promises](/language/v1-compatibility-promises). |
| 36 | + |
| 37 | +## Format Summary |
| 38 | + |
| 39 | +The following sections describe the JSON output format by example, using a pseudo-JSON notation. |
| 40 | +Important elements are described with comments, which are prefixed with `//`. |
| 41 | +To avoid excessive repetition, we've split the complete format into several discrete sub-objects, described under separate headers. References wrapped in angle brackets (like `<block-representation>`) are placeholders which, in the real output, would be replaced by an instance of the specified sub-object. |
| 42 | + |
| 43 | +The JSON output format consists of the following objects and sub-objects: |
| 44 | + |
| 45 | +- [Function Signature Representation](#function-signature-representation) - the top-level object returned by `terraform metadata functions -json` |
| 46 | +- [Parameter Representation](#parameter-representation) - a sub-object of signatures that describes their parameters |
| 47 | + |
| 48 | +## Function Signature Representation |
| 49 | + |
| 50 | +```javascript |
| 51 | +{ |
| 52 | + "format_version": "1.0", |
| 53 | + |
| 54 | + // "function_signatures" describes the signatures for all |
| 55 | + // available functions. |
| 56 | + "function_signatures": { |
| 57 | + // keys in this map are the function names, such as "abs" |
| 58 | + "example_function": { |
| 59 | + // "description" is an English-language description of |
| 60 | + // the purpose and usage of the function in Markdown. |
| 61 | + "description": "string", |
| 62 | + |
| 63 | + // "return_type" is a representation of a type specification |
| 64 | + // that the function returns. |
| 65 | + "return_type": "string", |
| 66 | + |
| 67 | + // "parameters" is an optional list of the positional parameters |
| 68 | + // that the function accepts. |
| 69 | + "parameters": [ |
| 70 | + <parameter-representation>, |
| 71 | + … |
| 72 | + ], |
| 73 | + |
| 74 | + // "variadic_parameter" is an optional representation of the |
| 75 | + // additional arguments that the function accepts after those |
| 76 | + // matching with the fixed parameters. |
| 77 | + "variadic_parameter": <parameter-representation> |
| 78 | + }, |
| 79 | + "example_function_two": { … } |
| 80 | + } |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | +## Parameter Representation |
| 85 | + |
| 86 | +A parameter representation describes a parameter to a function. |
| 87 | + |
| 88 | +```javascript |
| 89 | +{ |
| 90 | + // "name" is the internal name of the parameter |
| 91 | + "name": "string", |
| 92 | + |
| 93 | + // "description" is an optional English-language description of |
| 94 | + // the purpose and usage of the parameter in Markdown. |
| 95 | + "description": "string", |
| 96 | + |
| 97 | + // "type" is a representation of a type specification |
| 98 | + // that the parameter's value must conform to. |
| 99 | + "type": "string" |
| 100 | +} |
| 101 | +``` |
0 commit comments