Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output tasks still logs to console despite output: 'file' option #227

Open
samcarswell opened this issue Jul 15, 2024 · 3 comments
Open

Comments

@samcarswell
Copy link

We're using the below to output terraform output to a file:

  - task: TerraformTaskV4@4
    displayName: terraform output
    inputs:
      provider: 'azurerm'
      command: 'output'
      outputTo: 'file'
      workingDirectory: ${{parameters.workingDirectory}}
      environmentServiceNameAzureRM: $(azureConnection)
    name: TerraformOutput

This works, however it also prints the terraform output to the console in addition to the file, which I would not expect.
This is especially a problem if the terraform output values contain secrets, as these are displayed in plain text

@Midnighter
Copy link

While I completely agree with the sentiment, I also want output written to file only and parse from there, the docs are quite clear that outputTo can only be used with the show or custom commands.

Options specific to show

outputTo*: (console or file). You can choose to save output to file or only show output in console (i.e log)
outputFormat*: (json or default) . Output in json or default format

Options specific to custom
When selecting custom you can use any command that is supported natively by terraform.

customCommand*: pass any command that is supported natively by terraform
outputTo*: (console or file).You can choose to save output to file or only show output in console (i.e log)

@Midnighter
Copy link

Just to be clear, you can achieve the desired behavior with the following code, but I agree with OP that hiding console output would provide clearer semantics.

      - task: TerraformTaskV4@4
        name: terraformOutput
        displayName: Write Terraform Output Variables
        inputs:
          command: custom
          customCommand: output
          commandOptions: -json
          outputTo: file

You can then access that file with terraformOutput.customFilePath.

@stehubhex
Copy link

Hi , I am using a the custom command and have outputTo: 'file' but I cant see a file being created. Is it outputting it to the same directory or a different one ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants