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

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