--- page_title: "ona_team_membership Resource - ona" subcategory: "Identity and Access" description: |- Ona team membership. Use this resource to assign one existing user to one team for usage attribution and budgeting. --- # ona_team_membership (Resource) Ona team membership. Use this resource to assign one existing user to one team for usage attribution and budgeting. Teams group users for usage reporting and budgets. Team membership does not grant access; use groups for access control. Only users can be team members, and a user can belong to only one team in an organization. Use the `ona_user` data source to resolve a user by email and login provider, then pass its `user_id` to this resource. Moving a user between teams replaces the membership by removing the old membership before creating the new one. Do not set `create_before_destroy` on this resource. For product context, see [Manage teams](https://ona.com/docs/ona/organizations/teams). ## Example Usage ```terraform resource "ona_team" "platform" { name = "Platform Engineering" } data "ona_user" "alice" { email = "alice@example.com" login_provider = "github" } resource "ona_team_membership" "alice" { team_id = ona_team.platform.id user_id = data.ona_user.alice.user_id } ``` ## Schema ### Required - `team_id` (String) Team ID to assign the user to. Changing this value replaces the membership after removing the old one. - `user_id` (String) Existing user ID to assign to the team. Resolve users by email and login provider with the ona_user data source. Changing this value replaces the membership. ### Read-Only - `id` (String) Team membership ID. ## Import Import an existing membership with `team_id/user_id`. The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: ```shell #!/usr/bin/env sh terraform import ona_team_membership.alice 11111111-1111-4111-8111-111111111111/33333333-3333-4333-8333-333333333333 ```