We just released a alpha for v1.7 yesterday.
In the alpha you can reference variables and outputs from run blocks in your provider configurations. This should allow you to create a setup module that uses one provider, load credentials or configuration you need for a second provider from the first provider, and then pass the required data into the second provider.
For example:
# testing/setup/main.tf
data "vault_generic_secret" "aws_credentials" {
path = "some/path/to/secret"
}
output "aws_access_key_id" {
sensitive = true
value = data.vault_generic_secret.aws_credentials.data["AWS_ACCESS_KEY_ID"]
}
output "aws_secret_access_key" {
sensitive = true
value = data.vault_generic_secret.aws_credentials.data["AWS_SECRET_ACCESS_KEY"]
}
# tests/main.tftest.hcl
provider "vault" {
// ... some configuration ...
}
provider "aws" {
region = "us-west-2"
access_key = run.setup.aws_access_key_id
secret_key = run.setup.aws_secret_access_key
}
run "setup" {
module {
source = "./testing/setup"
}
}
run "test" {
// ... a normal testing block ...
}
This should make it possible to chain provider configurations together.
We are looking for feedback on this feature, and for anyone who has any provider configuration in tests requirements not met by this feature!
Thanks!