github.com/hugorut/terraform@v1.1.3/website/docs/language/functions/dirname.mdx (about)

     1  ---
     2  page_title: dirname - Functions - Configuration Language
     3  description: The dirname function removes the last portion from a filesystem path.
     4  ---
     5  
     6  # `dirname` Function
     7  
     8  `dirname` takes a string containing a filesystem path and removes the last
     9  portion from it.
    10  
    11  This function works only with the path string and does not access the
    12  filesystem itself. It is therefore unable to take into account filesystem
    13  features such as symlinks.
    14  
    15  If the path is empty then the result is `"."`, representing the current
    16  working directory.
    17  
    18  The behavior of this function depends on the host platform. On Windows systems,
    19  it uses backslash `\` as the path segment separator. On Unix systems, the slash
    20  `/` is used. The result of this function is normalized, so on a Windows system
    21  any slashes in the given path will be replaced by backslashes before returning.
    22  
    23  Referring directly to filesystem paths in resource arguments may cause
    24  spurious diffs if the same configuration is applied from multiple systems or on
    25  different host operating systems. We recommend using filesystem paths only
    26  for transient values, such as the argument to [`file`](/language/functions/file) (where
    27  only the contents are then stored) or in `connection` and `provisioner` blocks.
    28  
    29  ## Examples
    30  
    31  ```
    32  > dirname("foo/bar/baz.txt")
    33  foo/bar
    34  ```
    35  
    36  ## Related Functions
    37  
    38  * [`basename`](/language/functions/basename) returns _only_ the last portion of a filesystem
    39    path, discarding the portion that would be returned by `dirname`.