feat: add onepassword_environment datasource for 1Password Environments#344
feat: add onepassword_environment datasource for 1Password Environments#344
Conversation
Add a Terraform datasource that reads environment variables from a 1Password Environment using the 1Password Go SDK Environments API. Supported only with service account or desktop app authentication; returns a clear error when used with 1Password Connect. - Add GetEnvironmentVariables to Client interface and implement in SDK client (beta SDK v0.4.1-beta.1) and Connect client (error response). - Add onepassword_environment datasource with environment_id, id, variables map, and variable block list. - Add e2e test. - Bump onepassword-sdk-go to v0.4.1-beta.1 for Environments support.
There was a problem hiding this comment.
Thank you @SimonBarendse this is awesome 👏 🔥
I left a few small comments but overall everything looks great. Test with both service account and desktop auth and everything worked as expected. In regards to using variables_map or not I think I agree with your approach here. The use case for the section list/map is a bit different from how users would use environments (ex: passing a map into environment blocks), so favouring the map as the primary with variables and using metadata for the detailed list is reasonable.
We will want to update our own dev portal docs with this change to highlight this feature, but I can reach out to the team to coordinate that before a release.
This should not end up in plan/outputs. Great catch from Jill in PR review. Co-authored-by: Jill Regan <[email protected]>
environment_id is already Required: true in the schema, so Terraform will already error on empty value. The explicit check here isn't needed. Great catch from Jill in PR review. Co-authored-by: Jill Regan <[email protected]>
Great catch from Jill in PR review. Co-authored-by: Jill Regan <[email protected]>
|
Thanks Jill, great catches! 🙌 I agree with all your suggestions and applied them. |
JillRegan
left a comment
There was a problem hiding this comment.
Approved 🚀 Will cut a release shortly!
✨ Summary
Add a Terraform datasource that reads environment variables from a 1Password Environment using the 1Password Go SDK Environments API. Supported only with service account or desktop app authentication; returns a clear error when used with 1Password Connect.
🔗 Resolves
#302
✅ Checklist
🕵️ Review Notes &⚠️ Risks
I've chosen to expose both a key/value map for convenience as well as the detailed metadata as a separate field. This matches a.o. a pattern in this repo for how we're exposing item sections as well (section block + section map).
I've deviated from the
<name>_mappattern used there, to default the user towards the most convenient option of the map and make explicit the list is intended for metadata use cases. Keen for feedback on this and happy to switch to usingvariables_mapinstead if that's preferred for consistency.