You can use terraform dirname() to get only the file path without the file name. dirname() takes a string containing a filesystem path and removes the file name and returns only the directory name.
Syntax: dirname(file_path)
Example:
1 2 3 4 5 6 7 8 9 10 |
## Open terraform console terraform console ## Get only file path without the file name dirname("/home/debjeet/main.tf") ## returns "/home/debjeet" ## Get only file name from filepath basename("/home/debjeet/main.tf") ## returns "main.tf" |