Search code examples
terraformazure-pipelinespipelineterraform-provider-azure

Too many command line arguments Terraform plan


I am new to terraform. I am trying to create a simple storage account through azure pipeline, however when I run my pipeline I get the error "Too many command line arguments". I am struck and I do not know what I am doing wrong. Can someone please help.

this is my plan script in pipeline:

- script:
    terraform plan -out = plan.tfplan    
  displayName: Terraform plan
  workingDirectory: $(System.DefaultWorkingDirectory)/terraform
  env:
    ARM_CLIENT_ID: $(application_id)
    ARM_CLIENT_SECRET: $(client_secret)
    ARM_TENANT_ID: $(tenant_id)
    ARM_SUBSCRIPTION_ID: $(subscription_id)
    TF_VAR_client_id: $(application_id) 
    TF_VAR_tenant_id: $(tenant_id) 
    TF_VAR_subscription_id: $(subscription_id) 
    TF_VAR_client_secret: $(client_secret

The error that I am getting:

Starting: Terraform plan

Generating script.
Script contents:
terraform plan -out = plan.tfplan
========================== Starting Command Output ===========================
/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/3d07140f-ec17-4bfc-9384-a1170fae1248.sh
╷
│ Error: Too many command line arguments
│ 
│ To specify a working directory for the plan, use the global -chdir flag.
╵

For more help on using this command, run:
  terraform plan -help
##[error]Bash exited with code '1'.
Finishing: Terraform plan


Solution

  • This has extra spaces, which are not valid:

    terraform plan -out = plan.tfplan  
    

    It should be like the following:

    terraform plan -out=plan.tfplan