There was already the same topic but it was closed due to 30 days inactivity.
I still wanted to give the work around I’m using since I believe it will help others.
Lets assume you need to access an external api with an api key that differ in test and prod.
Here is the way I have vault variable based on the active environment.
It is a 3 steps process:
Define put the api keys in the vault:
- external_api_key_test: t3sts3cr3t
- external_api_key_prod: pr0ds3cr3t
- …
Define less sensitive info in the environments
Test environment variables
- vault_suffix: test
- external_api_base_url: https://test.external-api.com
- …
Prod environment variables
- vault_suffix: prod
- external_api_base_url: https://external-api.com
Request Authorization (or directly on the collection)
- Auth Type: Api Key
- Key: api-key
- Value: {{vault:external_api_key_{{vault_suffix}}}} // Here stands the magic
- Add to: Header
Hope it helped.