terraform-provider-onepassword icon indicating copy to clipboard operation
terraform-provider-onepassword copied to clipboard

Add support for document data source

Open sdahlbac opened this issue 11 months ago • 4 comments

I have have only tested this with unittests and cli, as I do not have a connect.

  • Supports multiple files
  • Supports text documents and binary documents (provided one uses the content_base64 version)

Roundtrip test:

data "onepassword_item" "foo" {
  vault = var.demo_vault
  uuid  = "..."
}
resource "local_file" "truststore" {
  filename       = "truststore.jks"
  content_base64 = data.onepassword_item.foo.file.2.content_base64
}

(where 2 is the third file for that item, added via the UI)

I had to use the op read approach rather than op document get (unless I am missing an undocumented feature) to be able to handle multiple files.

I have not tried to implement a resource, since as far as I understood connect cannot support it and I don't see a way to distinguish between the two backends.

~~The document category is available also for resource, that is slightly incorrect.~~

sdahlbac avatar Mar 20 '24 20:03 sdahlbac

This looks related to #51. I have a connect API setup for my Kubernetes clusters, I might be able to test this if I get some time to build and deploy your branch.

estenrye avatar Apr 04 '24 13:04 estenrye

Ran go generate to get updated docs, but it seems that terraform-plugin-docs fails to include descriptions of nested fields 😢 EDIT: turns out that the descriptions are already missing in terraform providers schema -json

sdahlbac avatar Apr 18 '24 11:04 sdahlbac

@volodymyrZotov comments adressed

sdahlbac avatar Apr 23 '24 13:04 sdahlbac

Speculating with myself: Actually, the fact that descriptions are missing from the schema might be a slight issue if things like sensitive: true is also missing

sdahlbac avatar Apr 23 '24 19:04 sdahlbac

It seems that the cheese has been moved (due to #167). I'll see if I can figure out what changes are needed due to the change of tf framework.

Also, it seems that #164 is somewhat related.

sdahlbac avatar May 16 '24 13:05 sdahlbac

Ok, I have something that seems to work locally against main. Will create a superseding PR when I have cleaned up it a little bit more.

sdahlbac avatar May 16 '24 21:05 sdahlbac

Superceded by #171

@volodymyrZotov would you review that one instead, please?

sdahlbac avatar May 17 '24 13:05 sdahlbac

@sdahlbac Hi, was about to write to you that there was a migration and you would need to adjust your PR because of that, but I see you figured it out already 👍 Will take another look there.

volodymyrZotov avatar May 17 '24 18:05 volodymyrZotov