Skip to content

Commit 14f89bf

Browse files
committed
Enhance documentation and tests for github_organization_network_configuration resource
1 parent cf2a393 commit 14f89bf

4 files changed

Lines changed: 59 additions & 7 deletions

github/resource_github_organization_network_configuration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func resourceGithubOrganizationNetworkConfiguration() *schema.Resource {
4949
Elem: &schema.Schema{
5050
Type: schema.TypeString,
5151
},
52-
Description: "The identifier of the network settings to use for the network configuration. Exactly one network settings must be specified.",
52+
Description: "An array containing exactly one network settings ID. A network settings resource can only be associated with one network configuration at a time.",
5353
},
5454
"id": {
5555
Type: schema.TypeString,

github/resource_github_organization_network_configuration_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func TestAccGithubOrganizationNetworkConfiguration(t *testing.T) {
1212
t.Run("creates organization network configuration without error", func(t *testing.T) {
1313
networkSettingsID := os.Getenv("GITHUB_TEST_NETWORK_SETTINGS_ID")
1414
if networkSettingsID == "" {
15-
t.Skip("Skipping test: GITHUB_TEST_NETWORK_SETTINGS_ID not set")
15+
t.Skip("GITHUB_TEST_NETWORK_SETTINGS_ID not set")
1616
}
1717

1818
config := fmt.Sprintf(`
@@ -74,15 +74,14 @@ func TestAccGithubOrganizationNetworkConfiguration(t *testing.T) {
7474
t.Run("updates organization network configuration without error", func(t *testing.T) {
7575
networkSettingsID := os.Getenv("GITHUB_TEST_NETWORK_SETTINGS_ID")
7676
if networkSettingsID == "" {
77-
t.Skip("Skipping test: GITHUB_TEST_NETWORK_SETTINGS_ID not set")
77+
t.Skip("GITHUB_TEST_NETWORK_SETTINGS_ID not set")
7878
}
7979

8080
name := "test-network-config-one"
8181
computeService := "actions"
8282

8383
updatedName := "test-network-config-two"
8484
updatedComputeService := "actions"
85-
updatedNetworkSettingsID := networkSettingsID
8685

8786
configs := map[string]string{
8887
"before": fmt.Sprintf(`
@@ -97,7 +96,7 @@ func TestAccGithubOrganizationNetworkConfiguration(t *testing.T) {
9796
name = "%s"
9897
compute_service = "%s"
9998
network_settings_ids = ["%s"]
100-
}`, updatedName, updatedComputeService, updatedNetworkSettingsID),
99+
}`, updatedName, updatedComputeService, networkSettingsID),
101100
}
102101

103102
checks := map[string]resource.TestCheckFunc{
@@ -126,7 +125,7 @@ func TestAccGithubOrganizationNetworkConfiguration(t *testing.T) {
126125
),
127126
resource.TestCheckResourceAttr(
128127
"github_organization_network_configuration.test",
129-
"network_settings_ids.0", updatedNetworkSettingsID,
128+
"network_settings_ids.0", networkSettingsID,
130129
),
131130
),
132131
}
@@ -164,7 +163,7 @@ func TestAccGithubOrganizationNetworkConfiguration(t *testing.T) {
164163
t.Run("imports organization network configuration without error", func(t *testing.T) {
165164
networkSettingsID := os.Getenv("GITHUB_TEST_NETWORK_SETTINGS_ID")
166165
if networkSettingsID == "" {
167-
t.Skip("Skipping test: GITHUB_TEST_NETWORK_SETTINGS_ID not set")
166+
t.Skip("GITHUB_TEST_NETWORK_SETTINGS_ID not set")
168167
}
169168

170169
name := "test-network-config-import"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
layout: "github"
3+
page_title: "GitHub: github_organization_network_configuration"
4+
description: |-
5+
Creates and manages network configurations for GitHub Actions hosted runners in an organization.
6+
---
7+
8+
# github_organization_network_configuration
9+
10+
This resource allows you to create and manage network configurations for GitHub Actions hosted runners in a GitHub Organization. Network configurations enable you to configure networking settings for hosted compute services.
11+
12+
~> **Note:** This resource is only available for GitHub Enterprise Cloud organizations. See the [GitHub documentation](https://docs.github.com/en/enterprise-cloud@latest/rest/orgs/network-configurations) for more information.
13+
14+
## Example Usage
15+
16+
```hcl
17+
resource "github_organization_network_configuration" "example" {
18+
name = "my-network-config"
19+
compute_service = "actions"
20+
network_settings_ids = ["23456789ABDCEF1"]
21+
}
22+
```
23+
24+
## Argument Reference
25+
26+
The following arguments are supported:
27+
28+
* `name` - (Required) The name of the network configuration. Must be between 1 and 100 characters and may only contain upper and lowercase letters a-z, numbers 0-9, '.', '-', and '_'.
29+
30+
* `compute_service` - (Optional) The hosted compute service to use for the network configuration. Can be one of `none` or `actions`. Defaults to `none`.
31+
32+
* `network_settings_ids` - (Required) An array containing exactly one network settings ID. Network settings resources are configured separately through your cloud provider (e.g., Azure). **Note:** A network settings resource can only be associated with one network configuration at a time.
33+
34+
## Attributes Reference
35+
36+
The following additional attributes are exported:
37+
38+
* `id` - The ID of the network configuration.
39+
40+
* `created_on` - The timestamp when the network configuration was created.
41+
42+
## Import
43+
44+
Organization network configurations can be imported using the network configuration ID:
45+
46+
```
47+
$ terraform import github_organization_network_configuration.example 1234567890ABCDEF
48+
```
49+
50+
The network configuration ID can be found using the [List network configurations](https://docs.github.com/en/enterprise-cloud@latest/rest/orgs/network-configurations#list-hosted-compute-network-configurations-for-an-organization) API endpoint.

website/github.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,9 @@
331331
<li>
332332
<a href="/docs/providers/github/r/organization_role_user.html">organization_role_user</a>
333333
</li>
334+
<li>
335+
<a href="/docs/providers/github/r/organization_network_configuration.html">github_organization_network_configuration</a>
336+
</li>
334337
<li>
335338
<a href="/docs/providers/github/r/organization_ruleset.html">github_organization_ruleset</a>
336339
</li>

0 commit comments

Comments
 (0)