github.com/nirarg/terraform@v0.11.12-beta1/scripts/debug-terraform (about)

     1  #!/usr/bin/env bash
     2  
     3  # This is a helper script to launch Terraform inside the "dlv" debugger,
     4  # configured to await a remote debugging connection on port 2345. You can
     5  # then connect to it using the following command, or its equivalent in your
     6  # debugging frontend of choice:
     7  #    dlv connect 127.0.0.1:2345
     8  #
     9  # This tool does not install dlv. To install it, see its instructions:
    10  #    https://github.com/derekparker/delve/tree/master/Documentation/installation
    11  #
    12  # For more convenient use, you may wish to put this script in your PATH:
    13  #    ln -s ../src/github.com/hashicorp/terraform/scripts/debug-terraform $GOPATH/bin/debug-terraform
    14  #
    15  # Note that when running this script the Terraform binary is NOT in $GOPATH/bin,
    16  # so any providers installed there won't be found unless Terraform searches
    17  # there for some _other_ reason.
    18  
    19  set -eu
    20  
    21  # Make sure we're debugging the process where the code is actually running.
    22  # (This also, as a side effect, causes raw logs to go directly to stderr,
    23  # and panics to be expressed directly, since we lose the log/panic wrapper.)
    24  export TF_FORK=0
    25  
    26  echo "Launching Terraform in a headless debug session"
    27  echo "Connect to it using: dlv connect 127.0.0.1:2345"
    28  echo "(Terraform takes a long time to build and launch in this mode; some logs will appear below)"
    29  echo "---------------------------"
    30  
    31  exec dlv debug github.com/hashicorp/terraform --headless --listen :2345 --log -- "$@"