How can I fix provider.vault: no vault token found?

Viewed 2411

Here're the official docs about vault provider and the thing is:

provider "vault" {
  version = "2.10.0"
  address = "..."
}

I did set both VAULT_ADDR and VAULT_TOKEN:

terraform plan -lock=false dev/foo_dev
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.aws_iam_policy_document.foo_doc: Refreshing state...

------------------------------------------------------------------------

Error: Error running plan: 1 error occurred:
        * provider.vault: no vault token found
make: *** [plan] Error 1
āœ— echo $VAULT_ADDR 
...
āœ— echo $VAULT_TOKEN
...

token - (Required) Vault token that will be used by Terraform to authenticate. May be set via the VAULT_TOKEN environment variable.

If I remove address = "..." I can see the same error so it can't retrieve VAULT_ADDR either.

1 Answers

Did you export the variables? You need to use

export VAULT_TOKEN=s.123456789abc
export VAULT_ADDR=vault.company.org

not just

VAULT_TOKEN=s.123456789abc
VAULT_ADDR=vault.company.org

otherwise terraform won't see those variables.

Related