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

Running Terraform output command returns no result #517

Open
AshOfSpades opened this issue Apr 27, 2023 · 1 comment
Open

Running Terraform output command returns no result #517

AshOfSpades opened this issue Apr 27, 2023 · 1 comment

Comments

@AshOfSpades
Copy link

Describe the bug

When I run terraform output command in the AWSShellScript task (after a successfult terraform apply task) it returns {}, However if I group it with terraform apply it provides all the outputs without any problem.

So basically this returns just {} with no outputs whatsoever -

  - task: AWSShellScript@1
    displayName: 'display output variables'
    name: TerraformOutput
    inputs:
      workingDirectory: $(Pipeline.Workspace)/terraform
      scriptType: 'inline'
      inlineScript: |
        terraform output -json
      awsCredentials: ${{ parameters.awsCreds }}

But if instead of having a separate task for terraform apply, if I include terraform apply in the same task, it works perfectly fine.

  - task: AWSShellScript@1
    displayName: 'display output variables'
    name: TerraformOutput
    inputs:
      workingDirectory: $(Pipeline.Workspace)/terraform
      scriptType: 'inline'
      inlineScript: |
        terraform apply --auto-approve
        terraform output -json
      awsCredentials: ${{ parameters.awsCreds }}

Expected behavior

Running just terraform output should return the output as result in logs

Your Environment

  • On-prem or cloud based?: AWS cloud
  • AWS Toolkit for Azure DevOps version: 1.13.0
@AshOfSpades
Copy link
Author

Another thing which I noticed is if I add change directory command it works -

- task: AWSShellScript@1
    displayName: 'display output variables'
    name: TerraformOutput
    inputs:
      workingDirectory: $(Pipeline.Workspace)/terraform
      scriptType: 'inline'
      inlineScript: |
        cd $(Pipeline.Workspace)/terraform
        terraform output -json
      awsCredentials: ${{ parameters.awsCreds }}

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

1 participant