Skip to content

Commit a072ae2

Browse files
Add AllowMemberTokenManagement to Team
1 parent 3ee83a9 commit a072ae2

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
## Unreleased
22

3+
<<<<<<< HEAD
34
ENHANCEMENTS:
45
* `d/tfe_project`: Add `workspace_names` attribute, by @1natedawg [#1429](https://github.com/hashicorp/terraform-provider-tfe/pull/1429)
56

7+
FEATURES:
8+
* `r/tfe_team`: Add attribute `allow_member_token_management` to `tfe_team` by @juliannatetreault [#1398](https://github.com/hashicorp/terraform-provider-tfe/pull/1398)
9+
610
BUG FIXES:
711
* `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)
812

internal/provider/resource_tfe_team.go

Lines changed: 14 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,10 @@ func resourceTFETeamCreate(d *schema.ResourceData, meta interface{}) error {
190195
options.SSOTeamID = tfe.String(v.(string))
191196
}
192197

198+
if v, ok := d.GetOk("allow_member_token_management"); ok {
199+
options.AllowMemberTokenManagement = tfe.Bool(v.(bool))
200+
}
201+
193202
log.Printf("[DEBUG] Create team %s for organization: %s", name, organization)
194203
team, err := config.Client.Teams.Create(ctx, organization, options)
195204
if err != nil {
@@ -250,6 +259,7 @@ func resourceTFETeamRead(d *schema.ResourceData, meta interface{}) error {
250259
}
251260
d.Set("visibility", team.Visibility)
252261
d.Set("sso_team_id", team.SSOTeamID)
262+
d.Set("allow_member_token_management", team.AllowMemberTokenManagement)
253263

254264
return nil
255265
}
@@ -297,6 +307,10 @@ func resourceTFETeamUpdate(d *schema.ResourceData, meta interface{}) error {
297307
options.SSOTeamID = tfe.String("")
298308
}
299309

310+
if v, ok := d.GetOk("allow_member_token_management"); ok {
311+
options.AllowMemberTokenManagement = tfe.Bool(v.(bool))
312+
}
313+
300314
log.Printf("[DEBUG] Update team: %s", d.Id())
301315
_, err := config.Client.Teams.Update(ctx, d.Id(), options)
302316
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", "false"),
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)