You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Terraform provides builtin functions to help users build reusable configuration.
Without consulting the documentation users may not always know:
functions names available
purpose of the function
signature (arguments & outputs) of each function
Technical Details
Functions are considered to be expression types within HCL and each version of Terraform may contain different functions or the implementation of functions may differ.
User Impact
Any user which uses functions in their configuration would be impacted.
Expected User Experience
User will be guided to get names of functions, arguments and outputs right, and understand what a function does without leaving their editor.
Completion
Given a configuration
resource"aws_vpc""example" {
cidr_block=# HERE
}
when user requests completion in the highlighted position, aside from other candidates (such as references), they're presented with function names compatible with the field type (i.e. functions which return string in the above example as cidr_block is of type string):
When user hovers over format they're provided with a description of the function, such as:
format(spec, values...)
format produces a string by formatting a number of other values according to a specification string. It is similar to the printf function in C, and other similar functions in other programming languages.
The name of a valid function, such as format will be highlighted semantically as function name, name of an invalid function (such as frmt) will not. That way user can tell a difference between typo-ed function name and correct one just from the colours.
Function signature
resource"aws_vpc""example" {
cidr_block=format(
After picking function name from completion popup, or typing a "trigger character" ( user is presented with function signature. They're also presented with details relevant to an argument relevant to the position after typing (or completing) "trigger character" ,.
The user-visible content presented is similar to the one presented via hover, except that here we also document each parameter individually, i.e.
specstring - The specification is a string that includes formatting verbs that are introduced with the % character.
valuesstring - Values to be formatted per specification
Proposal
hcl-lang to allow registering function signatures, or whole functions (depending on implementation)
terraform-schema to provide function signatures, or whole functions
Blocking Questions
Do we want to decouple functions entirely from Terraform Core, maintain a copy somewhere, or provide a way for TF Core to expose functions?
This was all released as part of v0.31.0 which is already part of the preview extension and will be part of the next stable release (2.26.0) which is expected to land 🔜 .
There are some related issues to follow-up on which are being tracked separately:
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Related to
Problem Statement
Terraform provides builtin functions to help users build reusable configuration.
Without consulting the documentation users may not always know:
Technical Details
Functions are considered to be expression types within HCL and each version of Terraform may contain different functions or the implementation of functions may differ.
User Impact
Any user which uses functions in their configuration would be impacted.
Expected User Experience
User will be guided to get names of functions, arguments and outputs right, and understand what a function does without leaving their editor.
Completion
Given a configuration
when user requests completion in the highlighted position, aside from other candidates (such as references), they're presented with function names compatible with the field type (i.e. functions which return string in the above example as
cidr_block
is of type string):Hover
When user hovers over
format
they're provided with a description of the function, such as:Semantic highlighting
The name of a valid function, such as
format
will be highlighted semantically as function name, name of an invalid function (such asfrmt
) will not. That way user can tell a difference between typo-ed function name and correct one just from the colours.Function signature
After picking function name from completion popup, or typing a "trigger character"
(
user is presented with function signature. They're also presented with details relevant to an argument relevant to the position after typing (or completing) "trigger character",
.The user-visible content presented is similar to the one presented via hover, except that here we also document each parameter individually, i.e.
The specification is a string that includes formatting verbs that are introduced with the % character.
Values to be formatted per specification
Proposal
hcl-lang
to allow registering function signatures, or whole functions (depending on implementation)terraform-schema
to provide function signatures, or whole functionsBlocking Questions
The text was updated successfully, but these errors were encountered: