Skip to content

Commit 9eaa972

Browse files
authored
Cloud User Group Resources (#292)
* Add support for cloud user groups * Add cloud group tests * Add cloud group members test * Update tests * Add docs * Remove support for SCIM groups for now * Update to newest sdk release * Remove group access from resource * Add a group access test * Fix test * Fix test * Update docs * Fix linter error * Fix tests * Fix tests --------- Co-authored-by: Brian Kassouf <[email protected]>
1 parent 065d5ea commit 9eaa972

File tree

12 files changed

+1268
-0
lines changed

12 files changed

+1268
-0
lines changed

docs/resources/group.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "temporalcloud_group Resource - terraform-provider-temporalcloud"
4+
subcategory: ""
5+
description: |-
6+
Provisions a Temporal Cloud User Group.
7+
---
8+
9+
# temporalcloud_group (Resource)
10+
11+
Provisions a Temporal Cloud User Group.
12+
13+
## Example Usage
14+
15+
```terraform
16+
terraform {
17+
required_providers {
18+
temporalcloud = {
19+
source = "temporalio/temporalcloud"
20+
}
21+
}
22+
}
23+
24+
provider "temporalcloud" {
25+
26+
}
27+
28+
resource "temporalcloud_namespace" "namespace" {
29+
name = "terraform"
30+
regions = ["aws-us-east-1"]
31+
accepted_client_ca = base64encode(file("${path.module}/ca.pem"))
32+
retention_days = 14
33+
}
34+
35+
resource "temporalcloud_group" "namespace_admin_group" {
36+
name = "developers"
37+
}
38+
39+
resource "temporalcloud_group_access" "namespace_admin_group_access" {
40+
group_id = temporalcloud_group.namespace_admin_group.id
41+
account_access = "developer"
42+
namespace_accesses = [
43+
{
44+
namespace_id = temporalcloud_namespace.namespace.id
45+
permission = "admin"
46+
}
47+
]
48+
}
49+
```
50+
51+
<!-- schema generated by tfplugindocs -->
52+
## Schema
53+
54+
### Required
55+
56+
- `name` (String) The name of the group
57+
58+
### Optional
59+
60+
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
61+
62+
### Read-Only
63+
64+
- `id` (String) The unique identifier of the group.
65+
- `state` (String) The current state of the group.
66+
67+
<a id="nestedblock--timeouts"></a>
68+
### Nested Schema for `timeouts`
69+
70+
Optional:
71+
72+
- `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
73+
- `delete` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.
74+
75+
## Import
76+
77+
Import is supported using the following syntax:
78+
79+
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
80+
81+
```shell
82+
# Groups can be imported to incorporate existing Groups into your Terraform pipeline.
83+
# To import a Group, you need
84+
# - a resource configuration in your Terraform configuration file/module to accept the imported Group. In the example below, the placeholder is "temporalcloud_group" "group"
85+
# - the Group's ID, which is found using the Temporal Cloud CLI tcld g l. In the example below, this is 72360058153949edb2f1d47019c1e85f
86+
87+
terraform import temporalcloud_group.group 72360058153949edb2f1d47019c1e85f
88+
```

docs/resources/group_members.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "temporalcloud_group_members Resource - terraform-provider-temporalcloud"
4+
subcategory: ""
5+
description: |-
6+
Sets Group Membership for the provided Group ID. Only use one per group.
7+
---
8+
9+
# temporalcloud_group_members (Resource)
10+
11+
Sets Group Membership for the provided Group ID. Only use one per group.
12+
13+
## Example Usage
14+
15+
```terraform
16+
terraform {
17+
required_providers {
18+
temporalcloud = {
19+
source = "temporalio/temporalcloud"
20+
}
21+
}
22+
}
23+
24+
provider "temporalcloud" {
25+
26+
}
27+
28+
resource "temporalcloud_group" "admin_group" {
29+
name = "admins"
30+
}
31+
32+
resource "temporalcloud_user" "reader" {
33+
34+
account_access = "reader"
35+
}
36+
37+
resource "temporalcloud_group_access" "admin_group_access" {
38+
group_id = temporalcloud_group.admin_group.id
39+
account_access = "admin"
40+
}
41+
42+
resource "temporalcloud_group_members" "admin_group_members" {
43+
group_id = temporalcloud_group.admin_group.id
44+
users = [
45+
temporalcloud_user.reader.id,
46+
]
47+
}
48+
```
49+
50+
<!-- schema generated by tfplugindocs -->
51+
## Schema
52+
53+
### Required
54+
55+
- `group_id` (String) The Group ID to set the members for.
56+
- `users` (Set of String) The users to add to the group.
57+
58+
### Optional
59+
60+
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
61+
62+
### Read-Only
63+
64+
- `id` (String) The unique identifier of the group.
65+
66+
<a id="nestedblock--timeouts"></a>
67+
### Nested Schema for `timeouts`
68+
69+
Optional:
70+
71+
- `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
72+
- `delete` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.
73+
74+
## Import
75+
76+
Import is supported using the following syntax:
77+
78+
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
79+
80+
```shell
81+
# Group Members can be imported to incorporate existing Group Memberships into your Terraform pipeline.
82+
# To import Group Members, you need
83+
# - a resource configuration in your Terraform configuration file/module to accept the imported Group Members. In the example below, the placeholder is "temporalcloud_group_members" "group"
84+
# - the Group's ID, which is found using the Temporal Cloud CLI tcld g l. In the example below, this is 72360058153949edb2f1d47019c1e85f
85+
86+
terraform import temporalcloud_group_members.group 72360058153949edb2f1d47019c1e85f
87+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Groups can be imported to incorporate existing Groups into your Terraform pipeline.
2+
# To import a Group, you need
3+
# - a resource configuration in your Terraform configuration file/module to accept the imported Group. In the example below, the placeholder is "temporalcloud_group" "group"
4+
# - the Group's ID, which is found using the Temporal Cloud CLI tcld g l. In the example below, this is 72360058153949edb2f1d47019c1e85f
5+
6+
terraform import temporalcloud_group.group 72360058153949edb2f1d47019c1e85f
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
terraform {
2+
required_providers {
3+
temporalcloud = {
4+
source = "temporalio/temporalcloud"
5+
}
6+
}
7+
}
8+
9+
provider "temporalcloud" {
10+
11+
}
12+
13+
resource "temporalcloud_namespace" "namespace" {
14+
name = "terraform"
15+
regions = ["aws-us-east-1"]
16+
accepted_client_ca = base64encode(file("${path.module}/ca.pem"))
17+
retention_days = 14
18+
}
19+
20+
resource "temporalcloud_group" "namespace_admin_group" {
21+
name = "developers"
22+
}
23+
24+
resource "temporalcloud_group_access" "namespace_admin_group_access" {
25+
group_id = temporalcloud_group.namespace_admin_group.id
26+
account_access = "developer"
27+
namespace_accesses = [
28+
{
29+
namespace_id = temporalcloud_namespace.namespace.id
30+
permission = "admin"
31+
}
32+
]
33+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Group Members can be imported to incorporate existing Group Memberships into your Terraform pipeline.
2+
# To import Group Members, you need
3+
# - a resource configuration in your Terraform configuration file/module to accept the imported Group Members. In the example below, the placeholder is "temporalcloud_group_members" "group"
4+
# - the Group's ID, which is found using the Temporal Cloud CLI tcld g l. In the example below, this is 72360058153949edb2f1d47019c1e85f
5+
6+
terraform import temporalcloud_group_members.group 72360058153949edb2f1d47019c1e85f
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
terraform {
2+
required_providers {
3+
temporalcloud = {
4+
source = "temporalio/temporalcloud"
5+
}
6+
}
7+
}
8+
9+
provider "temporalcloud" {
10+
11+
}
12+
13+
resource "temporalcloud_group" "admin_group" {
14+
name = "admins"
15+
}
16+
17+
resource "temporalcloud_user" "reader" {
18+
19+
account_access = "reader"
20+
}
21+
22+
resource "temporalcloud_group_access" "admin_group_access" {
23+
group_id = temporalcloud_group.admin_group.id
24+
account_access = "admin"
25+
}
26+
27+
resource "temporalcloud_group_members" "admin_group_members" {
28+
group_id = temporalcloud_group.admin_group.id
29+
users = [
30+
temporalcloud_user.reader.id,
31+
]
32+
}

internal/provider/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ func (p *TerraformCloudProvider) Resources(ctx context.Context) []func() resourc
175175
NewMetricsEndpointResource,
176176
NewNexusEndpointResource,
177177
NewNamespaceExportSinkResource,
178+
NewUserGroupResource,
179+
NewUserGroupMembersResource,
178180
NewGroupAccessResource,
179181
NewConnectivityRuleResource,
180182
}

0 commit comments

Comments
 (0)