Can't use password field in another provider

TnT
TnT
Community Member

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

Comments

  • tyla
    tyla
    1Password Alumni

    Hey TnT,

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

  • 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

This discussion has been closed.