Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data source can not access sections #187

Open
mrohlof-protofy opened this issue Jul 3, 2024 · 5 comments
Open

data source can not access sections #187

mrohlof-protofy opened this issue Jul 3, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@mrohlof-protofy
Copy link

Your environment

Terraform Provider Version: 2.1.0
Connect Server Version:
CLI Version: 2.28
OS: macOS Sonoma 14.5
Terraform Version: 1.8.3

What happened?

When I read an 1pw item as data source, I can not access sections in that item. It worked prior to 2.0.0. I can access sections of a resource, though.

Example

resource "onepassword_item" "test" {
  vault = var.onepassword_vault
  title = "1pw-mre-test"
  section {
    label = "section-label"
    field {
      label = "field-label"
      value = "field-value1"
    }
  }
}

# reading section from resource works
output "output_resource" {
  depends_on = [onepassword_item.test]
  value = onepassword_item.test.section[0]
  sensitive = true
}

data "onepassword_item" "test" {
  depends_on = [onepassword_item.test]
  title = "1pw-mre-test"
  vault = var.onepassword_vault
}

# reading section from data source does not work
output "output_datasource" {
  depends_on = [data.onepassword_item.test]
  value = data.onepassword_item.test.section[0]
  sensitive = true
}

Applying this gives the following error:


│ Error: Invalid index
│ 
│   on main.tf line 55, in output "out":
│   55:   value = data.onepassword_item.test.section[0]
│     ├────────────────
│     │ data.onepassword_item.test.section is empty list of object
│ 
│ The given key does not identify an element in this collection value: the collection has no elements.

What did you expect to happen?

I expected to receive the first section.

Steps to reproduce

  1. Create item with section
  2. Read item as data source
  3. Read section with id 0 from data source
@mrohlof-protofy mrohlof-protofy added the bug Something isn't working label Jul 3, 2024
@josh-thisisbud
Copy link

I have been having similar issues, although I've managed to get the 1password sections to start appearing if I add a new section with a label via the webui. This is obviously unacceptable as a solution/workaround, but it's something at least. I don't get any of the fields though, no matter what I do.

@rawkode
Copy link

rawkode commented Jul 25, 2024

I've hit this too. I'm using Terraform CDK and this is currently the interface for SectionFields:

export interface DataOnepasswordItemSectionField {
}

@josh-thisisbud
Copy link

I am also using Terraform CDK

@josh-thisisbud
Copy link

I reverted to 1.4.0 and I can get the data through, but I also had to move all the fields to a newly created section with a label

@eviscares
Copy link

This is still an issue with 2.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants