concourseconcourse-pipeline

concourse ci job parameterization


i want to parametrize jobs for different envs.

for example:

  resources:
  - name: prod
    type: terraform
    icon: terraform
    source: 
      backend_type: s3
      backend_config: 
        env_name: prod
        bucket: 
        key: 
      env:
        AWS_ACCESS_KEY_ID: ((aws-sts:prod.access_key))
        AWS_SECRET_ACCESS_KEY: ((aws-sts:prod.secret_key))
        AWS_SESSION_TOKEN: ((aws-sts:prod.security_token))
        AWS_REGION: ((vault:kv/my-vault.region))

jobs: 
    - name: terraform plan prod 
      disable_manual_trigger: true
      plan:
        - get: git-repo-prod
          trigger: true
        - put: prod
          params:
            env_name: prod
            terraform_source: git-repo-prod/terraform
            plan_only: true
            vars:
              region: ((vault:kv/my-vault.region))
      

2 questions:

  1. How can i create template for this job. For example now i have job terraform plan prod and i would like to have 1 template for different jobs with different envs. terraform plan * (prod/ppe/qa/dev)
  2. how to manage vars with files?
vars:
    region: ((vault:kv/my-vault.region))

i can use vars_file but i this case concourse transfers variables as a sting to terraform ( region: ((vault:kv/my-vault.region)) something like this)

Is it any possibilities to do this in concourse?


Solution

  • Try changing

    vars:
      region: ((vault:kv/my-vault.region))
    

    to

    vars: ((vault:kv/my-vault))
    

    When concourse encounters a field with sub-fields (that aren't value in the case of Vault), it treats them as an object type to be rendered in yaml. Good luck!