Skip to main content
April 7, 2022
Question

Can't use password field in another provider

  • April 7, 2022
  • 2 replies
  • 276 views

Hi,

i try to use the terraform onepassword provider to fetch token for another provider in this way:

```
terraform {
required_providers {
hcloud = {
source = "hetznercloud/hcloud"
}
onepassword = {
source = "1Password/onepassword"
}
}
}

provider "onepassword" {
url = "http://localhost:8080"
}

data "onepassword_item" "hcloud_token" {
vault = "the-uuid"
title = "Hetzner Cloud Token - Test"
}

provider "hcloud" {
token = data.onepassword_item.hcloud_token.password
}
```

When i use data.onepassword_item.hcloud_token.password i get the error "The argument "token" is required, but no definition was found."

After several try & error iterations i then copied the token in the url field in 1password and used data.onepassword_item.hcloud_token.url and this works. In both fields is exact the same string. Any idea why i cant use the password field here?


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided

2 replies

tyla
1Password Employee
May 6, 2022

Hey TnT,

Just wanted let you know that we're looking into it and will be responding soon ;)

May 9, 2022

Hey TnT,

I can confirm that you should be able to reference the password field of an item in the provider config like you have shown.

One thing that I would like to check is that you have set the OP_CONNECT_TOKEN environment variable to the Token created for your connect server. The 1Password provider requires a token to populate the password datasource. If that value is not set in the provider or the environment variable it can also result in a "The argument "token" is required, but no definition was found." error from Terraform since both providers expect a token