Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ade5ab5
feat(utils): add shared helper functions for cost centers
github-actions[bot] Feb 4, 2026
b1fb4e7
feat(cost-centers): add retry logic utilities for cost center operations
github-actions[bot] Feb 4, 2026
5531bfe
feat(cost-centers): add github_enterprise_cost_center resource
github-actions[bot] Feb 4, 2026
7413302
feat(cost-centers): add github_enterprise_cost_center_users resource
github-actions[bot] Feb 4, 2026
023ecf7
feat(cost-centers): add github_enterprise_cost_center_organizations r…
github-actions[bot] Feb 4, 2026
efcec0c
feat(cost-centers): add github_enterprise_cost_center_repositories re…
github-actions[bot] Feb 4, 2026
2b36273
feat(cost-centers): add data sources for enterprise cost centers
github-actions[bot] Feb 4, 2026
7f8950a
feat(cost-centers): register cost center resources and data sources
github-actions[bot] Feb 4, 2026
f153510
docs(cost-centers): add usage example
github-actions[bot] Feb 4, 2026
91c18dd
fix(cost-centers): update go-github import to v82
github-actions[bot] Feb 4, 2026
a77624e
fix: removed linter config, it shouldn't be needed
vmvarela Feb 9, 2026
977c197
fix(cost-centers): remove unnecessary expandStringSet function
vmvarela Feb 9, 2026
71498bc
fix(cost-centers): check deleted state in Read instead of Update
vmvarela Feb 9, 2026
14c9cc8
fix(cost-centers): separate Create and Update for users resource
vmvarela Feb 9, 2026
99ae8d3
fix(cost-centers): separate Create and Update for organizations resource
vmvarela Feb 9, 2026
90ee7cc
fix(cost-centers): separate Create and Update for repositories resource
vmvarela Feb 9, 2026
92e7f60
fix(cost-centers): correct resource type strings in CheckDestroy func…
vmvarela Feb 9, 2026
55f4cbf
refactor(cost-centers): use type constants instead of magic strings
vmvarela Feb 9, 2026
f1fa841
fix(cost-centers): use terraform-plugin-testing imports in test files
vmvarela Feb 14, 2026
e513cb3
fix(cost-centers): document generic chunk helper lint exception
vmvarela Feb 17, 2026
fa610ad
fix: address review - rename single-char variables and remove unneces…
vmvarela Feb 18, 2026
553d8ca
fix: address review - rename maxResourcesPerRequest to maxCostCenterR…
vmvarela Feb 18, 2026
c9e8c33
fix: address review - simplify import test with ImportStateIdPrefix
vmvarela Feb 18, 2026
5d51fb3
fix: address review - add unit tests for errIs404, errIsRetryable, ch…
vmvarela Feb 18, 2026
cbe311a
fix: address review - migrate cost center tests to ConfigStateChecks
vmvarela Feb 18, 2026
44e296e
fix(cost-centers): update go-github import from v82 to v83
vmvarela Feb 23, 2026
7b9eb6c
fix(cost-centers): add default 'all' value to state field in cost cen…
vmvarela Feb 23, 2026
757d0b2
fix(cost-center): populate name on import via API lookup
vmvarela Feb 24, 2026
3f852a8
fix(cost-center): align sub-resource IDs with main resource
vmvarela Feb 24, 2026
c6c7127
fix(cost-center): validate no existing assignments on Create
vmvarela Feb 24, 2026
c9ae2ef
refactor(cost-center): simplify Update diff with map pattern
vmvarela Feb 24, 2026
eeb8acc
fix(cost-center): Delete removes all linked resources from API
vmvarela Feb 24, 2026
ac65797
fix(cost-center): add missing sub-resources to website sidebar
vmvarela Feb 24, 2026
c17c220
fix: update go-github import to v84 and remove duplicate team helpers…
vmvarela Mar 18, 2026
a8faeb6
fix(cost-centers): use third-person verb in data source descriptions
vmvarela Mar 23, 2026
18f9d54
chore(lint): exclude modernize newexpr rule for Ptr calls
vmvarela Mar 23, 2026
a88420b
fix(cost-centers): remove defensive nil check and use deleteResourceO…
vmvarela Mar 23, 2026
10a75b8
fix: undo .golangci.yml changes
vmvarela Mar 25, 2026
7949ae1
fix: after rebase
vmvarela Apr 11, 2026
3051d4c
Merge branch 'main' into cost-centers
timja Jun 9, 2026
819de7e
Merge branch 'main' into cost-centers
eyalgal Jul 20, 2026
4c1c7b6
Merge branch 'main' into cost-centers
eyalgal Aug 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/data-sources/enterprise_cost_center.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
layout: "github"
page_title: "GitHub: github_enterprise_cost_center"
description: |-
Get a GitHub enterprise cost center by ID.
---

# github_enterprise_cost_center

Retrieves information about a specific GitHub enterprise cost center.

## Example Usage

```
data "github_enterprise_cost_center" "example" {
enterprise_slug = "example-enterprise"
cost_center_id = "cc_123456"
}
```

## Argument Reference

* `enterprise_slug` - (Required) The slug of the enterprise.
* `cost_center_id` - (Required) The ID of the cost center.

## Attributes Reference

* `name` - The name of the cost center.
* `state` - The state of the cost center.
* `azure_subscription` - The Azure subscription associated with the cost center.
* `users` - The usernames currently assigned to the cost center.
* `organizations` - The organization logins currently assigned to the cost center.
* `repositories` - The repositories currently assigned to the cost center.

33 changes: 33 additions & 0 deletions docs/data-sources/enterprise_cost_centers.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
layout: "github"
page_title: "GitHub: github_enterprise_cost_centers"
description: |-
List GitHub enterprise cost centers.
---

# github_enterprise_cost_centers

Retrieves a list of GitHub enterprise cost centers.

## Example Usage

```
data "github_enterprise_cost_centers" "active" {
enterprise_slug = "example-enterprise"
state = "active"
}
```

## Argument Reference

* `enterprise_slug` - (Required) The slug of the enterprise.
* `state` - (Optional) Filter cost centers by state. Valid values are `all`, `active`, and `deleted`. Defaults to `all`.

## Attributes Reference

* `cost_centers` - A set of cost centers.
* `id` - The cost center ID.
* `name` - The name of the cost center.
* `state` - The state of the cost center.
* `azure_subscription` - The Azure subscription associated with the cost center.

52 changes: 52 additions & 0 deletions docs/resources/enterprise_cost_center.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
layout: "github"
page_title: "GitHub: github_enterprise_cost_center"
description: |-
Create and manage a GitHub enterprise cost center.
---

# github_enterprise_cost_center

This resource allows you to create and manage a GitHub enterprise cost center.

~> **Note:** This resource manages only the cost center entity itself. To assign users, organizations, or repositories, use the separate `github_enterprise_cost_center_users`, `github_enterprise_cost_center_organizations`, and `github_enterprise_cost_center_repositories` resources.

Deleting this resource archives the cost center (GitHub calls this state `deleted`).

## Example Usage

```hcl
resource "github_enterprise_cost_center" "example" {
enterprise_slug = "example-enterprise"
name = "platform-cost-center"
}

# Use separate resources to manage assignments
resource "github_enterprise_cost_center_users" "example" {
enterprise_slug = "example-enterprise"
cost_center_id = github_enterprise_cost_center.example.id
usernames = ["alice", "bob"]
}
```

## Argument Reference

* `enterprise_slug` - (Required) The slug of the enterprise.
* `name` - (Required) The name of the cost center.

## Attributes Reference

The following additional attributes are exported:

* `id` - The cost center ID.
* `state` - The state of the cost center.
* `azure_subscription` - The Azure subscription associated with the cost center.

## Import

GitHub Enterprise Cost Center can be imported using the `enterprise_slug` and the `cost_center_id`, separated by a `:` character.

```
$ terraform import github_enterprise_cost_center.example example-enterprise:<cost_center_id>
```

45 changes: 45 additions & 0 deletions docs/resources/enterprise_cost_center_organizations.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
layout: "github"
page_title: "GitHub: github_enterprise_cost_center_organizations"
description: |-
Manages organization assignments to a GitHub enterprise cost center.
---

# github_enterprise_cost_center_organizations

This resource manages organization assignments to a GitHub enterprise cost center.

~> **Note:** This resource is authoritative. It will manage the full set of organizations assigned to the cost center. To add organizations without affecting other assignments, you must include all desired organizations in the `organization_logins` set.

## Example Usage

```hcl
resource "github_enterprise_cost_center" "example" {
enterprise_slug = "example-enterprise"
name = "platform-cost-center"
}

resource "github_enterprise_cost_center_organizations" "example" {
enterprise_slug = "example-enterprise"
cost_center_id = github_enterprise_cost_center.example.id
organization_logins = ["octo-org", "acme-corp"]
}
```

## Argument Reference

* `enterprise_slug` - (Required) The slug of the enterprise.
* `cost_center_id` - (Required) The ID of the cost center.
* `organization_logins` - (Required) Set of organization logins to assign to the cost center. Must contain at least one organization.

## Attributes Reference

This resource exports no additional attributes.

## Import

GitHub Enterprise Cost Center Organization assignments can be imported using the `enterprise_slug` and the `cost_center_id`, separated by a `:` character.

```
$ terraform import github_enterprise_cost_center_organizations.example example-enterprise:<cost_center_id>
```
45 changes: 45 additions & 0 deletions docs/resources/enterprise_cost_center_repositories.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
layout: "github"
page_title: "GitHub: github_enterprise_cost_center_repositories"
description: |-
Manages repository assignments to a GitHub enterprise cost center.
---

# github_enterprise_cost_center_repositories

This resource manages repository assignments to a GitHub enterprise cost center.

~> **Note:** This resource is authoritative. It will manage the full set of repositories assigned to the cost center. To add repositories without affecting other assignments, you must include all desired repositories in the `repository_names` set.

## Example Usage

```hcl
resource "github_enterprise_cost_center" "example" {
enterprise_slug = "example-enterprise"
name = "platform-cost-center"
}

resource "github_enterprise_cost_center_repositories" "example" {
enterprise_slug = "example-enterprise"
cost_center_id = github_enterprise_cost_center.example.id
repository_names = ["octo-org/my-app", "acme-corp/backend-service"]
}
```

## Argument Reference

* `enterprise_slug` - (Required) The slug of the enterprise.
* `cost_center_id` - (Required) The ID of the cost center.
* `repository_names` - (Required) Set of repository names (in `owner/repo` format) to assign to the cost center. Must contain at least one repository.

## Attributes Reference

This resource exports no additional attributes.

## Import

GitHub Enterprise Cost Center Repository assignments can be imported using the `enterprise_slug` and the `cost_center_id`, separated by a `:` character.

```
$ terraform import github_enterprise_cost_center_repositories.example example-enterprise:<cost_center_id>
```
45 changes: 45 additions & 0 deletions docs/resources/enterprise_cost_center_users.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
layout: "github"
page_title: "GitHub: github_enterprise_cost_center_users"
description: |-
Manages user assignments to a GitHub enterprise cost center.
---

# github_enterprise_cost_center_users

This resource manages user assignments to a GitHub enterprise cost center.

~> **Note:** This resource is authoritative. It will manage the full set of users assigned to the cost center. To add users without affecting other assignments, you must include all desired users in the `usernames` set.

## Example Usage

```hcl
resource "github_enterprise_cost_center" "example" {
enterprise_slug = "example-enterprise"
name = "platform-cost-center"
}

resource "github_enterprise_cost_center_users" "example" {
enterprise_slug = "example-enterprise"
cost_center_id = github_enterprise_cost_center.example.id
usernames = ["alice", "bob", "charlie"]
}
```

## Argument Reference

* `enterprise_slug` - (Required) The slug of the enterprise.
* `cost_center_id` - (Required) The ID of the cost center.
* `usernames` - (Required) Set of usernames to assign to the cost center. Must contain at least one username.

## Attributes Reference

This resource exports no additional attributes.

## Import

GitHub Enterprise Cost Center User assignments can be imported using the `enterprise_slug` and the `cost_center_id`, separated by a `:` character.

```
$ terraform import github_enterprise_cost_center_users.example example-enterprise:<cost_center_id>
```
115 changes: 115 additions & 0 deletions examples/cost_centers/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
terraform {
required_providers {
github = {
source = "integrations/github"
version = "~> 6.11"
}
}
}

provider "github" {
token = var.github_token
owner = var.enterprise_slug
}

variable "github_token" {
description = "GitHub classic personal access token (PAT) for an enterprise admin"
type = string
sensitive = true
}

variable "enterprise_slug" {
description = "The GitHub Enterprise slug"
type = string
}

variable "cost_center_name" {
description = "Name for the cost center"
type = string
}

variable "users" {
description = "Usernames to assign to the cost center"
type = list(string)
default = []
}

variable "organizations" {
description = "Organization logins to assign to the cost center"
type = list(string)
default = []
}

variable "repositories" {
description = "Repositories (full name, e.g. org/repo) to assign to the cost center"
type = list(string)
default = []
}

# The cost center resource manages only the cost center entity itself.
resource "github_enterprise_cost_center" "example" {
enterprise_slug = var.enterprise_slug
name = var.cost_center_name
}

# Use separate authoritative resources for assignments.
# These are optional - only create them if you have items to assign.

resource "github_enterprise_cost_center_users" "example" {
count = length(var.users) > 0 ? 1 : 0

enterprise_slug = var.enterprise_slug
cost_center_id = github_enterprise_cost_center.example.id
usernames = var.users
}

resource "github_enterprise_cost_center_organizations" "example" {
count = length(var.organizations) > 0 ? 1 : 0

enterprise_slug = var.enterprise_slug
cost_center_id = github_enterprise_cost_center.example.id
organization_logins = var.organizations
}

resource "github_enterprise_cost_center_repositories" "example" {
count = length(var.repositories) > 0 ? 1 : 0

enterprise_slug = var.enterprise_slug
cost_center_id = github_enterprise_cost_center.example.id
repository_names = var.repositories
}

# Data sources for reading cost center information
data "github_enterprise_cost_center" "by_id" {
enterprise_slug = var.enterprise_slug
cost_center_id = github_enterprise_cost_center.example.id
}

data "github_enterprise_cost_centers" "active" {
enterprise_slug = var.enterprise_slug
state = "active"

depends_on = [github_enterprise_cost_center.example]
}

output "cost_center" {
description = "Created cost center"
value = {
id = github_enterprise_cost_center.example.id
name = github_enterprise_cost_center.example.name
state = github_enterprise_cost_center.example.state
azure_subscription = github_enterprise_cost_center.example.azure_subscription
}
}

output "cost_center_from_data_source" {
description = "Cost center fetched by data source (includes all assignments)"
value = {
id = data.github_enterprise_cost_center.by_id.cost_center_id
name = data.github_enterprise_cost_center.by_id.name
state = data.github_enterprise_cost_center.by_id.state
users = sort(tolist(data.github_enterprise_cost_center.by_id.users))
organizations = sort(tolist(data.github_enterprise_cost_center.by_id.organizations))
repositories = sort(tolist(data.github_enterprise_cost_center.by_id.repositories))
}
}
Loading
Loading