Twingate / terraform-provider-twingate

Mozilla Public License 2.0
42 stars 11 forks source link

Create new assignment schema for users<>group #221

Closed alexmensch closed 1 year ago

alexmensch commented 1 year ago

Instead of the changes proposed in #65, we are going to introduce a new type of assignment resource. This change will be introduced in the v0.y.z major version, and we'll introduce an equivalent change for resources<>group assignments in a new v1.y.z major version.

--

Create a new twingate_users_group_assign resource

New functionality

Arguments

Notes

Example usage

# Assign all admin users to the twingate_group.admins group
resource "twingate_users_group_assign" "admins" {
    group_id = twingate_group.admins.id
    user_ids = local.admin_users
}

resource "twingate_group" "admins" {
    name = "Admin Users"
}

data "twingate_users" "all" { }

locals {
    admin_users = toset([for each in twingate_users.all : each.id if each.is_admin == true])
}

Create a new twingate_users_group_add resource

New functionality

Arguments

Notes

Example usage

# Add the user user@autoco.com to the twingate_group.admins group
resource "twingate_users_group_add" "additional_admins" {
    group_id = twingate_group.admins.id
    user_ids = local.additional_admins
}

resource "twingate_group" "admins" {
    name = "Admin Users"
}

data "twingate_users" "all" { }

locals {
    additional_admins = toset([for each in twingate_users.all : each.id if each.email == "user@autoco.com"])
}
tjstansell commented 1 year ago

I'd put some caution at bumping to v1.x.y as that implies you're moving out of the development phase and into stable version changes, assuming you're trying to follow semver. I think here you'd just bump x in v0.x.y. See https://semver.org/#spec-item-4

alexmensch commented 1 year ago

FYI @tjstansell I'm going to close out a number of issues around assignments and replace them with a single issue and a single new resource we're going to use for assignments.