terraformterragrunt

Get current working directory in terraform


I am running Terraform using Terragrunt so I am not actually certain about the path that the terraform is invoked from.

So I am trying to get the current working directory as follows:

resource null_resource "pwd" {
  triggers {
    always_run = "${uuid()}"
  }
  provisioner "local-exec" {
    command = "echo $pwd >> somefile.txt"
  }
}

However the resulting file is empty.

Any suggestions?


Solution

  • Try command = "echo $(pwd) > somefile.txt"