Terraform provider using dynamic IP

109 Views Asked by At

So i am with a tricky problem, i am using terraform to create an infrastructure on cloud and using the ip of the load balancer created by GCP to the IP address needed for the vault provider

provider "vault" {
  address = local.vault_add
  token   = ""
  version = "~> 2.14.0"
}  

but the terraform apply gives an error because it wont wait until the LB IP is generated and it will try to communicate with the Vault using the default value localhost. Is any way to solve this problem without split cofiguration of the Vault with the rest ?

1

There are 1 best solutions below

0
On

Not really - you will almost certainly find it best to configure Vault separately.

If you think about it for a moment, you will see that you have a chicken-and-egg situation: you want the Vault provider to pull secrets from Vault to support the creation of your infrastructure, but Vault doesn't exist yet, so there's nowhere to pull the secrets from. So you need Vault to set up your infrastructure, but you need to set up your infrastructure to have Vault.

Your best approach will be to set up Vault separately, then it will be running, unsealed, populated, and available to use for your other Terraform operations.