-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add coderd_organization_group_sync
resource
#248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "coderd_organization_group_sync Resource - terraform-provider-coderd" | ||
subcategory: "" | ||
description: |- | ||
Group sync settings for an organization on the Coder deployment. | ||
Multiple instances of this resource for a single organization will conflict. | ||
~> Warning | ||
This resource is only compatible with Coder version 2.16.0 https://github.com/coder/coder/releases/tag/v2.16.0 and later. | ||
--- | ||
|
||
# coderd_organization_group_sync (Resource) | ||
|
||
Group sync settings for an organization on the Coder deployment. | ||
Multiple instances of this resource for a single organization will conflict. | ||
|
||
~> **Warning** | ||
This resource is only compatible with Coder version [2.16.0](https://github.com/coder/coder/releases/tag/v2.16.0) and later. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "coderd_organization_group_sync" "test" { | ||
organization_id = coderd_organization.test.id | ||
field = "groups" | ||
regex_filter = "test_.*|admin_.*" | ||
auto_create_missing = false | ||
|
||
mapping = { | ||
"test_developers" = [coderd_group.test.id] | ||
"admin_users" = [coderd_group.admins.id] | ||
"mixed_group" = [coderd_group.test.id, coderd_group.admins.id] | ||
} | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `field` (String) The claim field that specifies what groups a user should be in. | ||
- `mapping` (Map of List of String) A map from OIDC group name to Coder group ID. | ||
- `organization_id` (String) The ID of the organization to configure group sync for. | ||
|
||
### Optional | ||
|
||
- `auto_create_missing` (Boolean) Controls whether groups will be created if they are missing. Defaults to false. | ||
- `regex_filter` (String) A regular expression that will be used to filter the groups returned by the OIDC provider. Any group not matched will be ignored. | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: | ||
|
||
```shell | ||
# The ID supplied must be an organization UUID | ||
$ terraform import coderd_organization_group_sync.main_group_sync <org-id> | ||
``` | ||
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used: | ||
|
||
```terraform | ||
import { | ||
to = coderd_organization_group_sync.main_group_sync | ||
id = "<org-id>" | ||
} | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# The ID supplied must be an organization UUID | ||
$ terraform import coderd_organization_group_sync.main_group_sync <org-id> | ||
``` | ||
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used: | ||
|
||
```terraform | ||
import { | ||
to = coderd_organization_group_sync.main_group_sync | ||
id = "<org-id>" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
resource "coderd_organization_group_sync" "test" { | ||
organization_id = coderd_organization.test.id | ||
field = "groups" | ||
regex_filter = "test_.*|admin_.*" | ||
auto_create_missing = false | ||
|
||
mapping = { | ||
"test_developers" = [coderd_group.test.id] | ||
"admin_users" = [coderd_group.admins.id] | ||
"mixed_group" = [coderd_group.test.id, coderd_group.admins.id] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
terraform { | ||
required_providers { | ||
coderd = { | ||
source = "coder/coderd" | ||
version = ">=0.0.0" | ||
} | ||
} | ||
} | ||
|
||
resource "coderd_organization" "test" { | ||
name = "test-org-group-sync" | ||
display_name = "Test Organization for Group Sync" | ||
description = "Organization created for testing group sync functionality" | ||
} | ||
|
||
resource "coderd_group" "test" { | ||
organization_id = coderd_organization.test.id | ||
name = "test-group" | ||
display_name = "Test Group" | ||
quota_allowance = 50 | ||
} | ||
|
||
resource "coderd_group" "admins" { | ||
organization_id = coderd_organization.test.id | ||
name = "admin-group" | ||
display_name = "Admin Group" | ||
quota_allowance = 100 | ||
} | ||
|
||
resource "coderd_organization_group_sync" "test" { | ||
organization_id = coderd_organization.test.id | ||
field = "groups" | ||
regex_filter = "test_.*|admin_.*" | ||
auto_create_missing = false | ||
|
||
mapping = { | ||
"test_developers" = [coderd_group.test.id] | ||
"admin_users" = [coderd_group.admins.id] | ||
"mixed_group" = [coderd_group.test.id, coderd_group.admins.id] | ||
} | ||
} | ||
|
||
data "coderd_organization" "test_data" { | ||
id = coderd_organization.test.id | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ import ( | |
) | ||
|
||
func checkRegexp(it string) error { | ||
_, err := regexp.Compile("") | ||
_, err := regexp.Compile(it) | ||
return err | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function was previously validating an empty string instead of the actual input. The fix correctly validates the input parameter Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks copilot, wouldn't have figured that out on my own |
||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.