Skip to content

Commit 66a5587

Browse files
authored
Merge pull request #1398 from hashicorp/juliannatetreault/TF-16200-add-team-token-management
Add AllowMemberTokenManagement to Team
2 parents 3ee83a9 + 3ece994 commit 66a5587

File tree

6 files changed

+44
-4
lines changed

6 files changed

+44
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
ENHANCEMENTS:
44
* `d/tfe_project`: Add `workspace_names` attribute, by @1natedawg [#1429](https://github.com/hashicorp/terraform-provider-tfe/pull/1429)
55

6+
FEATURES:
7+
* `r/tfe_team`: Add attribute `allow_member_token_management` to `tfe_team` by @juliannatetreault [#1398](https://github.com/hashicorp/terraform-provider-tfe/pull/1398)
8+
69
BUG FIXES:
710
* `r/tfe_workspace` html_url is now planned to be recomputed when `name` changes. Previously, changed values would show up on the next plan, by @brandonc [1422](https://github.com/hashicorp/terraform-provider-tfe/issues/1422)
811

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/hashicorp/go-multierror v1.1.1 // indirect
1313
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
1414
github.com/hashicorp/go-slug v0.15.2
15-
github.com/hashicorp/go-tfe v1.58.0
15+
github.com/hashicorp/go-tfe v1.62.0
1616
github.com/hashicorp/go-version v1.7.0
1717
github.com/hashicorp/hcl v1.0.0
1818
github.com/hashicorp/hcl/v2 v2.19.1 // indirect
@@ -28,9 +28,9 @@ require (
2828
golang.org/x/crypto v0.21.0 // indirect
2929
golang.org/x/net v0.23.0 // indirect
3030
golang.org/x/oauth2 v0.17.0 // indirect
31-
golang.org/x/sys v0.20.0 // indirect
31+
golang.org/x/sys v0.23.0 // indirect
3232
golang.org/x/text v0.14.0 // indirect
33-
golang.org/x/time v0.5.0 // indirect
33+
golang.org/x/time v0.6.0 // indirect
3434
google.golang.org/protobuf v1.33.0 // indirect
3535
)
3636

@@ -76,7 +76,7 @@ require (
7676
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
7777
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
7878
golang.org/x/mod v0.15.0 // indirect
79-
golang.org/x/sync v0.7.0 // indirect
79+
golang.org/x/sync v0.8.0 // indirect
8080
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
8181
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
8282
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ github.com/hashicorp/go-slug v0.15.2 h1:/ioIpE4bWVN/d7pG2qMrax0a7xe9vOA66S+fz7fZ
6868
github.com/hashicorp/go-slug v0.15.2/go.mod h1:THWVTAXwJEinbsp4/bBRcmbaO5EYNLTqxbG4tZ3gCYQ=
6969
github.com/hashicorp/go-tfe v1.58.0 h1:aJXrStDBG+YJLkgDYswfNiKTRHQxKqT/9C1VuvujRkE=
7070
github.com/hashicorp/go-tfe v1.58.0/go.mod h1:XnTtBj3tVQ4uFkcFsv8Grn+O1CVcIcceL1uc2AgUcaU=
71+
github.com/hashicorp/go-tfe v1.62.0 h1:YCosV7nUQLAnZ+oYN2Mco3pP2ZjqW+3P5utZgKYptGc=
72+
github.com/hashicorp/go-tfe v1.62.0/go.mod h1:QyiMW7cc0jCYeiY0qYDOy6V2T1YmlF+wOKs96rxITBA=
7173
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
7274
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
7375
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
@@ -187,6 +189,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
187189
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
188190
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
189191
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
192+
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
193+
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
190194
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
191195
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
192196
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -201,6 +205,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
201205
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
202206
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
203207
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
208+
golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM=
209+
golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
204210
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
205211
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
206212
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -212,6 +218,8 @@ golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
212218
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
213219
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
214220
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
221+
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
222+
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
215223
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
216224
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
217225
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=

internal/provider/resource_tfe_team.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ func resourceTFETeam() *schema.Resource {
141141
Type: schema.TypeString,
142142
Optional: true,
143143
},
144+
"allow_member_token_management": {
145+
Type: schema.TypeBool,
146+
Optional: true,
147+
Default: true,
148+
},
144149
},
145150
}
146151
}
@@ -190,6 +195,8 @@ func resourceTFETeamCreate(d *schema.ResourceData, meta interface{}) error {
190195
options.SSOTeamID = tfe.String(v.(string))
191196
}
192197

198+
options.AllowMemberTokenManagement = tfe.Bool(d.Get("allow_member_token_management").(bool))
199+
193200
log.Printf("[DEBUG] Create team %s for organization: %s", name, organization)
194201
team, err := config.Client.Teams.Create(ctx, organization, options)
195202
if err != nil {
@@ -250,6 +257,7 @@ func resourceTFETeamRead(d *schema.ResourceData, meta interface{}) error {
250257
}
251258
d.Set("visibility", team.Visibility)
252259
d.Set("sso_team_id", team.SSOTeamID)
260+
d.Set("allow_member_token_management", team.AllowMemberTokenManagement)
253261

254262
return nil
255263
}
@@ -297,6 +305,8 @@ func resourceTFETeamUpdate(d *schema.ResourceData, meta interface{}) error {
297305
options.SSOTeamID = tfe.String("")
298306
}
299307

308+
options.AllowMemberTokenManagement = tfe.Bool(d.Get("allow_member_token_management").(bool))
309+
300310
log.Printf("[DEBUG] Update team: %s", d.Id())
301311
_, err := config.Client.Teams.Update(ctx, d.Id(), options)
302312
if err != nil {

internal/provider/resource_tfe_team_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ func TestAccTFETeam_full(t *testing.T) {
5757
"tfe_team.foobar", "name", "team-test"),
5858
resource.TestCheckResourceAttr(
5959
"tfe_team.foobar", "visibility", "organization"),
60+
resource.TestCheckResourceAttr(
61+
"tfe_team.foobar", "allow_member_token_management", "true"),
6062
resource.TestCheckResourceAttr(
6163
"tfe_team.foobar", "organization_access.0.manage_policies", "true"),
6264
resource.TestCheckResourceAttr(
@@ -112,6 +114,8 @@ func TestAccTFETeam_full_update(t *testing.T) {
112114
"tfe_team.foobar", "name", "team-test"),
113115
resource.TestCheckResourceAttr(
114116
"tfe_team.foobar", "visibility", "organization"),
117+
resource.TestCheckResourceAttr(
118+
"tfe_team.foobar", "allow_member_token_management", "true"),
115119
resource.TestCheckResourceAttr(
116120
"tfe_team.foobar", "organization_access.0.manage_policies", "true"),
117121
resource.TestCheckResourceAttr(
@@ -154,6 +158,8 @@ func TestAccTFETeam_full_update(t *testing.T) {
154158
"tfe_team.foobar", "name", "team-test-1"),
155159
resource.TestCheckResourceAttr(
156160
"tfe_team.foobar", "visibility", "secret"),
161+
resource.TestCheckResourceAttr(
162+
"tfe_team.foobar", "allow_member_token_management", "false"),
157163
resource.TestCheckResourceAttr(
158164
"tfe_team.foobar", "organization_access.0.manage_policies", "false"),
159165
resource.TestCheckResourceAttr(
@@ -195,6 +201,8 @@ func TestAccTFETeam_full_update(t *testing.T) {
195201
"tfe_team.foobar", "name", "team-test-1"),
196202
resource.TestCheckResourceAttr(
197203
"tfe_team.foobar", "visibility", "secret"),
204+
resource.TestCheckResourceAttr(
205+
"tfe_team.foobar", "allow_member_token_management", "true"),
198206
resource.TestCheckResourceAttr(
199207
"tfe_team.foobar", "organization_access.0.manage_policies", "false"),
200208
resource.TestCheckResourceAttr(
@@ -461,6 +469,10 @@ func testAccCheckTFETeamAttributes_full(
461469
return fmt.Errorf("Bad visibility: %s", team.Visibility)
462470
}
463471

472+
if !team.AllowMemberTokenManagement {
473+
return fmt.Errorf("team.AllowMemberTokenManagement should be true")
474+
}
475+
464476
if !team.OrganizationAccess.ManagePolicies {
465477
return fmt.Errorf("OrganizationAccess.ManagePolicies should be true")
466478
}
@@ -511,6 +523,10 @@ func testAccCheckTFETeamAttributes_full_update(
511523
return fmt.Errorf("Bad visibility: %s", team.Visibility)
512524
}
513525

526+
if team.AllowMemberTokenManagement {
527+
return fmt.Errorf("team.AllowMemberTokenManagement should be false")
528+
}
529+
514530
if team.OrganizationAccess.ManagePolicies {
515531
return fmt.Errorf("OrganizationAccess.ManagePolicies should be false")
516532
}
@@ -596,6 +612,7 @@ resource "tfe_team" "foobar" {
596612
organization = tfe_organization.foobar.id
597613
598614
visibility = "organization"
615+
allow_member_token_management = true
599616
600617
organization_access {
601618
manage_policies = true
@@ -630,6 +647,7 @@ resource "tfe_team" "foobar" {
630647
organization = tfe_organization.foobar.id
631648
632649
visibility = "secret"
650+
allow_member_token_management = false
633651
634652
organization_access {
635653
manage_policies = false

website/docs/r/team.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ The following arguments are supported:
4141
* `visibility` - (Optional) The visibility of the team ("secret" or "organization"). Defaults to "secret".
4242
* `organization_access` - (Optional) Settings for the team's [organization access](https://developer.hashicorp.com/terraform/cloud-docs/users-teams-organizations/permissions#organization-permissions).
4343
* `sso_team_id` - (Optional) Unique Identifier to control [team membership](https://developer.hashicorp.com/terraform/cloud-docs/users-teams-organizations/single-sign-on#team-names-and-sso-team-ids) via SAML. Defaults to `null`
44+
* `allow_member_token_management` - (Optional) Used by Owners and users with "Manage Teams" permissions to control whether team members can manage team tokens. Defaults to `true`.
4445

4546
The `organization_access` block supports:
4647

0 commit comments

Comments
 (0)