tfutils/tfscaffold

Doesn't handle arguments after `--`

Opened this issue · 3 comments

So- when I'm trying to pass additional arguments to terraform call after --, those arguments aren't being propagated to any terraform call.

Example invocation:

bash -x ./bin/terraform.sh --action plan --project XXX --environment XXX --component XXX --bucket-prefix XXX --region eu-west-1 -- -var journal_sha256sum=wRFZ/rvP3I8H4what3v3r9/qSmD2b1kZRQ=

invocation of terraform plan later in the script:

terraform plan -input=false -refresh=true -module-depth=-1 -var region=eu-west-1 -var project=XXX -var bucket_name=XXX -var aws_account_id=XXX -var-file=../../etc/env_eu-west-1_XXX.tfvars

Would need more information to understand why this is happening for you. We use additional arguments for absolutely everything we do, so it certainly works in general.

You're executing with -x -- so where in the trace output are the args being dropped. During getopt?

Also, what OS is this being run on? Macs throw all kinds of troubles by not using GNU toolset by default.

I'm having this issue also.

Currently using 1.7.0. The command I am using is

tplan () {
    ./bin/terraform.sh -a 'plan' -c $1 -e $2 -p 'foo' -r 'eu-west-1' -b 'bar'
}

I have gnu-getopt installed via homebrew. The result of getopt_out=$(getopt -T) when running in my terminal is --.

I believe this is causing issues as I get the error message

ERROR: Non GNU getopt detected. If you're using a Mac then try "brew install gnu-getopt"

I have only started having this issue since using an M1 Macbook Pro, it was fine on my Intel chip. Do you have any advice please?

If you need any more information, just let me know!

@adamyaziji is the brew-installed version of getopt in your path?
which getopt should return something like /usr/local/opt/gnu-getopt/bin/getopt rather than /usr/bin/getopt - it seems like although you have installed it, you have not ensured that it is used instead of the system getopt?