Skip to content

feat: add onepassword_environment datasource for 1Password Environments#344

Merged
JillRegan merged 5 commits intomainfrom
simon/environment-data-source
Mar 11, 2026
Merged

feat: add onepassword_environment datasource for 1Password Environments#344
JillRegan merged 5 commits intomainfrom
simon/environment-data-source

Conversation

@SimonBarendse
Copy link
Member

✨ 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.

  • 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.

🔗 Resolves

#302

✅ Checklist

  • 🖊️ Commits are signed
  • 🧪 Tests added/updated: (See the Testing Guide for when to use each type and how to run them)
    • 🔹 Unit /🔸 Integration
    • 🌐 E2E
  • 📚 Docs updated (if behavior changed)

🕵️ 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>_map pattern 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 using variables_map instead if that's preferred for consistency.

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.
Copy link
Contributor

@JillRegan JillRegan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

SimonBarendse and others added 4 commits March 11, 2026 12:00
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]>
@SimonBarendse
Copy link
Member Author

Thanks Jill, great catches! 🙌

I agree with all your suggestions and applied them.

@SimonBarendse SimonBarendse added the enhancement New feature or request label Mar 11, 2026
Copy link
Contributor

@JillRegan JillRegan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved 🚀 Will cut a release shortly!

@JillRegan JillRegan merged commit b6b6c9c into main Mar 11, 2026
9 checks passed
@JillRegan JillRegan deleted the simon/environment-data-source branch March 11, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants