Get Secrets from multiple hashicorp vaults in one job

I want to know if it is possible, then how can I fetch secrets from 2 different hashicorp vault in one CI/CD job.

I have two vault servers, so there will be two VAULT_SERVER_URL with different Role and Token.

For example:

read_secret_via_token-id:
  stage: get_secret
  image: vault:1.13.3
  variables:
    VAULT_SERVER_URL: <vault-server-url->
    VAULT_AUTH_ROLE: <role>
  id_tokens:
    VAULT_ID_TOKEN:
      aud: <gitlab-url>
  secrets:
    POSTGRES_USERNAME:
      vault: database/postgres/postgres_username@kv2
      token: $VAULT_ID_TOKEN
      file: false
    POSTGRES_PASSWORD:
      vault: database/postgres/postgres_password@kv2
      token: $VAULT_ID_TOKEN
      file: false
  script:
    - echo "Fetched secret"
    - echo POSTGRES_USERNAME | base64
    - echo POSTGRES_PASSWORD | base64

Thank you in advance

Hi i also have the same issue, did you figure this out eventually?

Yes, I kept the job environment specific and added the vault url as the environment variable separate for each environment. and the same role for all envs (also in GitLab variables) but you can also keep separate roles for each environment…