Azure pipelines failing stating Incorrect task refrence

634 Views Asked by At

My Azure pipeline is as below:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'
steps:
- task: terraform init
  displayName: 'terraform init'
  inputs:
    provider: aws
    backendServiceAWS: 'tcp-aws-aa'
    backendAWSBucketName: 'terraform-backend-20200102'
    backendAWSKey: dev.plan

- task: terraform fmt
  displayName: 'terraform fmt'
  inputs:
    provider: aws
    command: fmt
    
- task: terraform validate
  displayName: 'terraform validate'
  inputs:
    provider: aws
    command: validate

- task: terraform plan
  displayName: 'terraform plan'
  inputs:
    provider: aws
    command: plan
    environmentServiceNameAWS: 'tcp-aws-aa'

- task: tflint check
  inputs:
    script: tflint .

- task: tfsec check
  inputs:
    script: tfsec .

However, it produces an error as like below

enter image description here

How to have it resolved?

1

There are 1 best solutions below

2
On BEST ANSWER

Well it looks like you want to refer to task: TerraformTaskV1@0 (based on the syntax) and the you should use as this:

- task: TerraformTaskV1@0
  inputs:
    provider: 'azurerm'
    command: 'init'
    backendAWSKey: 
    backendAWSBucketName: 

It support these commands:

enter image description here

And of course to use it you need to install this extension. I guessed that this is the one you should use based on the input settings. They are exactly the same like this extension has.

You also have there tflint and tfsec but I didn't found extensions or native solution for them so assuming that you installed them on agent you should rather use them like this:

- script: |
    tflint .
  displayName: 'tflint check'

- script: |
    tfsec .
  displayName: 'tfsec check'