Giter Site home page Giter Site logo

Comments (20)

Bouke avatar Bouke commented on July 28, 2024 3

I'm having the same problem. I'm running the plan action, however there's some unexpected additional command being run, as can be seen in the logs.

[command]C:\hostedtoolcache\windows\terraform\0.12.19\x64\terraform.exe version
Terraform v0.12.19
+ provider.azurerm v1.32.1
�[31mToo many command line arguments. Configuration path expected.�[0m�[0m
�[31mTerraform couldn't read the given file as a state or plan file.
The errors while attempting to read the file as each format are
shown below.

State read error: Error loading statefile: open d:\a\1\s\plan-binary-8d32fa13-73b6-4789-9e7e-541a0ef228ee.tfplan: The system cannot find the file specified.

Plan read error: open d:\a\1\s\plan-binary-8d32fa13-73b6-4789-9e7e-541a0ef228ee.tfplan: The system cannot find the file specified.�[0m�[0m

So... what is the extension doing, and why is it failing, and why is the failure not causing the task to fail?

from azure-pipelines-terraform.

pisxx-tests avatar pisxx-tests commented on July 28, 2024 3

Facing the same issue. Init and Validate work without any problems, Plan and Apply is unable to read remote state file.

Too many command line arguments. Configuration path expected.
Terraform couldn't read the given file as a state or plan file.
The errors while attempting to read the file as each format are
shown below.

State read error: Error loading statefile: open /home/vsts/work/1/s/plan-binary-db4ed225-a78a-4ca8-88bd-8ada715d9c2d.tfplan: no such file or directory

Plan read error: open /home/vsts/work/1/s/plan-binary-db4ed225-a78a-4ca8-88bd-8ada715d9c2d.tfplan: no such file or directory
Finishing: TerraformTaskV1

from azure-pipelines-terraform.

RTodorov avatar RTodorov commented on July 28, 2024 2

Hi folks,

Any news on this @Roshan-Kumar-Microsoft ? This seems to be happening with everyone. I have a very dummy pipeline and I'm also getting this error.

Thank you

from azure-pipelines-terraform.

Roshan-Kumar-Microsoft avatar Roshan-Kumar-Microsoft commented on July 28, 2024

@algattik Are you still blocked ? Can you please share your skype Id to [email protected] So we can debug it further.

from azure-pipelines-terraform.

algattik avatar algattik commented on July 28, 2024

The extension was not viable for me because of this outstanding issue (as well as microsoft/azure-pipelines-extensions#748 microsoft/azure-pipelines-extensions#725)
so I built a template that avoids all three and adds a facility for manual plan approval. https://github.com/algattik/terraform-azure-pipelines-starter

from azure-pipelines-terraform.

atcastel avatar atcastel commented on July 28, 2024

same issue here

from azure-pipelines-terraform.

ryeleo avatar ryeleo commented on July 28, 2024

Update

I noticed that the issue I am running into should be reported independently, so I opened a new issue: microsoft/azure-pipelines-extensions#820

Original comment

Same issue here, with a very basic pipeline that uses an Azure Storage Account for its backend (tfstate file). As a result, this plugin has no value to users who want to use the AzureRM "Storage Account" backend at this time.

I've captured the simplest example I could imagine in my azdevops-terraform-plugin-tinker github repository. I've copied the code below in this comment for you to review. Feel free to fork the repository and import this project into your Azure DevOps & Cloud!

image

DevOps Pipeline YAML

  • To test, replace all hardcoded values with valid values for your Azure Cloud/DevOps environment.
    • 'd88e0c85-dev-subscription'
    • 'terraform-rg'
    • 'terraform03'
    • 'tfstate'
# Simple example pipeline that simply aims to run terraform plan!
pool:
  vmImage: 'Ubuntu-18.04'
trigger: none

steps:
# Install Terraform
- task: TerraformInstaller@0
  inputs:
    terraformVersion: '0.12.24'
# Run 'terraform init'
- task: TerraformTaskV1@0
  inputs:
    provider: 'azurerm'
    command: 'init'
    workingDirectory: '.'
    backendServiceArm: 'd88e0c85-dev-subscription'
    backendAzureRmResourceGroupName: 'terraform-rg'
    backendAzureRmStorageAccountName: 'terraform03'
    backendAzureRmContainerName: 'tfstate'
    backendAzureRmKey: 'azdevops-terraform-plugin-tinker.tfstate'
# Run 'terraform plan'
- task: TerraformTaskV1@0
  inputs:
    provider: 'azurerm'
    command: 'plan'
    workingDirectory: '.'
    backendServiceArm: 'd88e0c85-dev-subscription'
    backendAzureRmResourceGroupName: 'terraform-rg'
    backendAzureRmStorageAccountName: 'terraform03'
    backendAzureRmContainerName: 'tfstate'
    backendAzureRmKey: 'azdevops-terraform-plugin-tinker.tfstate'

Terraform file.

  • To test, replace all hardcoded values with valid values for your Azure Cloud/DevOps environment.
    • "d88e0c85-6145-437a-99a3-64e8900098a7"
    • "terraform03"
    • "tfstate"
provider "azurerm" {
  version         = "~>2.0"
  subscription_id = "d88e0c85-6145-437a-99a3-64e8900098a7"
  features {}
}

terraform {
  backend "azurerm" {
    storage_account_name = "terraform03"
    container_name       = "tfstate"
    key                  = "azdevops-terraform-plugin-tinker.tfstate"
  }
}

from azure-pipelines-terraform.

LBoraz avatar LBoraz commented on July 28, 2024

getting the same error as described above. The init task doesn't print the error (too many arguments) despite accepting the same inputs. Not clear what this "too many arguments" are and why it can't read the state file (which seems to look for in the local disk, so why is it not accessible)?

from azure-pipelines-terraform.

philthynz avatar philthynz commented on July 28, 2024

Same issue for me:

image

from azure-pipelines-terraform.

bolanlesd avatar bolanlesd commented on July 28, 2024

Hi guys, we are having the same problems. Is anyone looking into this yet, please?

Regards.

from azure-pipelines-terraform.

Zia-Eurus avatar Zia-Eurus commented on July 28, 2024

getting the same error as described above.
terraform is trying to read the files(tfplan & tfstate) from my self-hosted agent as shown in the error... but my states files are the stores on the azure blob.. this error is coming when we try to update already provision resource
Need to check why terraform trying to access files from agent

from azure-pipelines-terraform.

tobys-playground avatar tobys-playground commented on July 28, 2024

me too. trying to create an AML workspace.

image

from azure-pipelines-terraform.

tomagb avatar tomagb commented on July 28, 2024

In my case the pipeline looks like this:

  displayName: 'Terraform Plan'
  inputs:
    provider: 'azurerm'
    command: 'plan'
    workingDirectory: '$(System.DefaultWorkingDirectory)/'
    commandOptions: -var mysql_connstr="$(mysql_connstr)"'
    environmentServiceNameAzureRM: 'DeployAutomationServicePrincipal'

The error Too many command line arguments comes from the missing quotes on the mysql_connstr variable value.
The connection string looks like this:

Data Source=someDb.mysql.database.azure.com;Database=someDb;User Id=someUserId;Password=somePassword

When inserted into the yaml it makes Terraform think that there are more than one argument.
I had to make sure "$(mysql_connstr)" is written instead of $(mysql_connstr).

from azure-pipelines-terraform.

ezekielg avatar ezekielg commented on July 28, 2024

@algattik Are you still blocked ? Can you please share your skype Id to [email protected] So we can debug it further.

Why is this still not fixed?

from azure-pipelines-terraform.

mericstam avatar mericstam commented on July 28, 2024

Hi, I am a part of Solidify AB, newly appointed maintainers of the terraform extension. I will take a look at this issue.

from azure-pipelines-terraform.

nishadmehendale avatar nishadmehendale commented on July 28, 2024

Facing this issue as well

from azure-pipelines-terraform.

ricohomewood avatar ricohomewood commented on July 28, 2024

Any update on this issue @mericstam ?

from azure-pipelines-terraform.

mlaver avatar mlaver commented on July 28, 2024

Bumped into this issue today aswell! Any workarounds available @mericstam ?

from azure-pipelines-terraform.

mericstam avatar mericstam commented on July 28, 2024

I am working on a V3 of the Terraform task where I have cleaned up the code some and split the functions to their respective command fixing some of these errors i.e the extra show command. We are also adding a 'custom' command option where you technically could use any command that terraform supports.

the workaround I found right now for plan command to use commandoptions and use -out=tfplan + any additional options and in the apply command use commandoptions: tfplan + any additional options
more info: https://www.terraform.io/cli/commands/plan#other-options

However reading the first comment from 2019, it has errors in it, commandoptions are not correct:
commandOptions: -out tfplan -var environment=${{ parameters.environment}} ${{ parameters.TerraformVariables }}

according to terraform manual. https://www.terraform.io/cli/commands/plan#input-variables-on-the-command-line
parameter out needs a = sign. ex. -out=filename, where filename is typically tfplan.

on linux and macOS agents you should use single quotes -var 'name=value'
on windows agents you should use double quotes -var "name=value"
This last part is untested just info from terraform docs. But worth testing out. probably need to escape the quotes in yaml pipeline, Not sure how Node will treat quotes..

from azure-pipelines-terraform.

mericstam avatar mericstam commented on July 28, 2024

I added a fix for the too many command line arguments in PR #39

from azure-pipelines-terraform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.