github.com/muratcelep/terraform@v1.1.0-beta2-not-internal-4/website/docs/language/expressions/function-calls.html.md (about)

     1  ---
     2  layout: "language"
     3  page_title: "Function Calls - Configuration Language"
     4  description: "Functions transform and combine values. Learn about Terraform's built-in functions."
     5  ---
     6  
     7  # Function Calls
     8  
     9  > **Hands-on:** Try the [Perform Dynamic Operations with Functions](https://learn.hashicorp.com/tutorials/terraform/functions?in=terraform/configuration-language&utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) tutorial on HashiCorp Learn.
    10  
    11  The Terraform language has a number of
    12  [built-in functions](/docs/language/functions/index.html) that can be used
    13  in expressions to transform and combine values. These
    14  are similar to the operators but all follow a common syntax:
    15  
    16  ```hcl
    17  <FUNCTION NAME>(<ARGUMENT 1>, <ARGUMENT 2>)
    18  ```
    19  
    20  The function name specifies which function to call. Each defined function
    21  expects a specific number of arguments with specific value types, and returns a
    22  specific value type as a result.
    23  
    24  Some functions take an arbitrary number of arguments. For example, the `min`
    25  function takes any amount of number arguments and returns the one that is
    26  numerically smallest:
    27  
    28  ```hcl
    29  min(55, 3453, 2)
    30  ```
    31  
    32  A function call expression evaluates to the function's return value.
    33  
    34  ## Available Functions
    35  
    36  For a full list of available functions, see
    37  [the function reference](/docs/language/functions/index.html).
    38  
    39  ## Expanding Function Arguments
    40  
    41  If the arguments to pass to a function are available in a list or tuple value,
    42  that value can be _expanded_ into separate arguments. Provide the list value as
    43  an argument and follow it with the `...` symbol:
    44  
    45  ```hcl
    46  min([55, 2453, 2]...)
    47  ```
    48  
    49  The expansion symbol is three periods (`...`), not a Unicode ellipsis character
    50  (`…`). Expansion is a special syntax that is only available in function calls.
    51  
    52  ## Using Sensitive Data as Function Arguments
    53  
    54  When using sensitive data, such as [an input variable](https://www.terraform.io/docs/language/values/variables.html#suppressing-values-in-cli-output)
    55  or [an output defined](https://www.terraform.io/docs/language/values/outputs.html#sensitive-suppressing-values-in-cli-output) as sensitive
    56  as function arguments, the result of the function call will be marked as sensitive.
    57  
    58  This is a conservative behavior that is true irrespective of the function being
    59  called. For example, passing an object containing a sensitive input variable to
    60  the `keys()` function will result in a list that is sensitive:
    61  
    62  ```shell
    63  > local.baz
    64  {
    65    "a" = (sensitive)
    66    "b" = "dog"
    67  }
    68  > keys(local.baz)
    69  (sensitive)
    70  ```
    71  
    72  ## When Terraform Calls Functions
    73  
    74  Most of Terraform's built-in functions are, in programming language terms,
    75  [pure functions](https://en.wikipedia.org/wiki/Pure_function). This means that
    76  their result is based only on their arguments and so it doesn't make any
    77  practical difference when Terraform would call them.
    78  
    79  However, a small subset of functions interact with outside state and so for
    80  those it can be helpful to know when Terraform will call them in relation to
    81  other events that occur in a Terraform run.
    82  
    83  The small set of special functions includes
    84  [`file`](/docs/language/functions/file.html),
    85  [`templatefile`](/docs/language/functions/templatefile.html),
    86  [`timestamp`](/docs/language/functions/timestamp.html),
    87  and [`uuid`](/docs/language/functions/uuid.html).
    88  If you are not working with these functions then you don't need
    89  to read this section, although the information here may still be interesting
    90  background information.
    91  
    92  The `file` and `templatefile` functions are intended for reading files that
    93  are included as a static part of the configuration and so Terraform will
    94  execute these functions as part of initial configuration validation, before
    95  taking any other actions with the configuration. That means you cannot use
    96  either function to read files that your configuration might generate
    97  dynamically on disk as part of the plan or apply steps.
    98  
    99  The `timestamp` function returns a representation of the current system time
   100  at the point when Terraform calls it, and the `uuid` function returns a random
   101  result which differs on each call. Without any special behavior, these would
   102  both cause the final configuration during the apply step not to match the
   103  actions shown in the plan, which violates the Terraform execution model.
   104  
   105  For that reason, Terraform arranges for both of those functions to produce
   106  [unknown value](references.html#values-not-yet-known) results during the
   107  plan step, with the real result being decided only during the apply step.
   108  For `timestamp` in particular, this means that the recorded time will be
   109  the instant when Terraform began applying the change, rather than when
   110  Terraform _planned_ the change.
   111  
   112  For more details on the behavior of these functions, refer to their own
   113  documentation pages.