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?

There isn’t a native way for concourse to template things for you. You’ll need to do that outside of concourse. People have used jsonnet and ytt to template concourse pipelines. I personally prefer ytt.

Not sure if this is exactly what you’re looking for, but here’s an example of how we templated a job in one of our pipelines: https://github.com/concourse/ci/blob/b8737d5887da9221f8155c9055c7a18d88fbd481/pipelines/resources/template.yml#L40-L54

A parent pipeline then renders and sets the templated pipeline. You can see that part here (reconfigure is our parent pipeline): https://github.com/concourse/ci/blob/b8737d5887da9221f8155c9055c7a18d88fbd481/pipelines/reconfigure.yml#L123-L129

Hopefully this helps a little!