Hello team,
I get the following error message “Error: failed to lookup token, err=Error making API request” after executing the terraform plan command
URL: GET http://127.0.0.1:8200/v1/auth/token/lookup-self
│ Code: 403. Errors:
│
│ * permission denied
│
│ with provider[“Terraform Registry”],
│ on main.tf line 12, in provider “vault”:
│ 12: provider “vault” {
Here is the code in the main.tf file
provider "vsphere" {
vsphere_server = var.vsphere_server
user = var.vsphere_user
password = data.vault_generic_secret.vcenterpass.data["password"]
allow_unverified_ssl = true
}
provider "vault" {
address = "http://127.0.0.1:8200/"
skip_tls_verify = true
token = var.vault_token
}
data "vault_generic_secret" "vcenterpass" {
path = "vcenter/vcenter_pass"
}
Vault is installed on a Windows environment.
The variables ‘VAULT_ADDR’, ‘VAULT_TOKEN’, ‘TF_VAR_vault_token’ have been created.
The main.tf file is based on the variables.tf and terraform.tfvars files.
Here are their contents :
variables.tf
variable "vsphere_server" {}
variable "vsphere_user" {}
variable "vsphere_password" {}
variable "vault_token" {}
terraform.tfvars
vsphere_server = "xxx.domain"
vsphere_user = "xxx@domain"
vsphere_password = "xxx"
vault_token = "TF_VAR_vault_token"
The default ACL policy in Vault
# Allow create tokens
path "auth/token/create" {
capabilities = ["create" , "read" , "list"]
}
# Allow tokens to look up their own properties
path "auth/token/lookup-self" {
capabilities = ["create" , "read" , "list"]
}
# Allow tokens to renew themselves
path "auth/token/renew-self" {
capabilities = ["update"]
}
The Vault configuration file config.hcl
disable_cache = true
disable_mlock = true
ui = true
listener "tcp" {
address = "0.0.0.0:8200"
tls_disable = 1
#tls_cert_file = "C:/Users/xxx/Downloads/Terraform/Vault/certs/vaultterraform.crt"
#tls_key_file = "C:/Users/xxx/Downloads/Terraform/Vault/certs/vaultterraform.key"
}
storage "file" {
path = "C:/Users/xxx/Downloads/Terraform/Vault/data"
}
api_addr = "http://0.0.0.0:8200"
max_lease_ttl = "10h"
default_lease_ttl = "10h"
cluster_name = "vault"
raw_storage_endpoint = true
disable_sealwrap = true
disable_printable_check = true
Does anyone see what the problem is ?
I’m both a newbie and not at ease with the English language.
Have a good day.
Thank you for your indulgence and future help.