Lime
Lime

Reputation: 11

Trying to send variables with terraform plan using concourse ci

I am trying to create a pipeline in concourse, which is going to trigger on github updates on a remote branch, and use that branch to plan, apply and destroy a terraform deployment.

- name: terraform-repo
  type: git
  icon: github
  source:
    uri: https://github.com/....

#docker image
- name: terraform-0-13-7
  type: registry-image
  source:
    repository: hashicorp/terraform
    tag: 0.13.7

jobs:
- name: terraform-deplyoment
  plan:
  - get: terraform-0-13-7
  - get: terraform-repo
    trigger: true

  - task: terraform-init
    image: terraform-0-13-7
    config:
      inputs:
      - name: terraform-repo
      outputs:
      - name: terraform-repo
      platform: linux
      run:
        path: terraform
        dir: terraform-repo
        args:
        - init

  - task: terraform-plan
    image: terraform-0-13-7
    config:
      inputs:
      - name: terraform-repo
      outputs:
      - name: terraform-repo
      platform: linux
      run:
        path: terraform
        dir: terraform-repo
        args:
        - plan
        params:
          variable1: "test"
          variable2: "test2"

This is erroring out on the concourse GUI when triggering the pipeline mentioning that the vars are not available. Am I doing something wrong with the syntax?

Upvotes: -1

Views: 718

Answers (1)

danilopopeye
danilopopeye

Reputation: 9998

The params are exposed to the task as environment variables so you should use them as input variables

  - task: terraform-plan
    image: terraform-0-13-7
    config:
      inputs:
      - name: terraform-repo
      outputs:
      - name: terraform-repo
      platform: linux
      run:
        path: terraform
        dir: terraform-repo
        args:
        - plan
        params:
          TF_VAR_variable1: "test"
          TF_VAR_variable2: "test2"

Upvotes: 1

Related Questions