Too many command line arguments. Did you mean to use -chdir?

Viewed 2594

I just run this line terraform init to initialize my terraform but it's always show this error

Folder structure

[ROOT]/terraform/main.tf
[ROOT]/src/lambda_code.py
[ROOT]/terraform/lambda.tf

Command

terraform init -input=false -backend=false ./terraform
terraform init validate ./terraform

Error:

Too many command line arguments. Did you mean to use -chdir?

In lambda.tf I package some file need to follow this structure, so I cannot go to terraform to init with ./terraform line

how to resolve that?

1 Answers

The error message Terraform returned is suggesting that you use the -chdir option, like this:

terraform -chdir=./terraform init -input=false -backend=false
terraform -chdir=./terraform validate

If you've encountered this while upgrading some existing automation scripts or runbooks for Terraform v0.15 or later, you may find more useful context in the upgrade guide entry about this new error.

Related