integrations / integrations/terraform-provider-github

[BUG]: github_enterprise_organization fails during create

Open
#2,598 3 comments 2 reactions 0 assignees View on GitHub
r/enterprise_organization Status: Triage Type: Bug
Dominant language
Go
Stars
1.2k
Forks
1k
Avg merge
1d 14h
Merged PRs (30d)
8

Description

### Expected Behavior

New organization should be created successfully.

### Actual Behavior

Terraform resource creation fails withing a few seconds of starting, with an error of 404 Not Found. The new org is actually created with the desired name but no additional settings have been applied.

This is being run from a GitHub Action workflow. The apply fails about 50% of the time, breaking the workflow.

### Terraform Version

Terraform 1.11.2, 1.11.0, 1.10.5
on Linux AMD64
Provider Version 6.5.0, 6.3.1, 6.3.0

### Affected Resource(s)

- github_enterprise_organization

### Terraform Configuration Files

```hcl
terraform {
backend "local" {
path = "../terraform.tfstate"
}
required_providers {
github = {
source = "integrations/github"
version = "6.5.0"
}
}
}
provider "github" {
token = var.gh_token
}
data "github_enterprise" "gh_ent" {
slug = ""
}
resource "github_enterprise_organization" "gh_org" {
depends_on = [
null_resource.wait_for_entra_sync
]
enterprise_id = data.github_enterprise.gh_ent.id
name = var.gh_org_name
display_name = var.gh_org_display_name
description = var.gh_org_description
billing_email = var.gh_org_billing_email
admin_logins = var.gh_org_admins

lifecycle {
ignore_changes = [
billing_email,
name,
]
}
}
```

### Steps to Reproduce

terraform apply

### Debug Output

```shell
2025-03-16T19:58:36.819Z [INFO] Starting apply for github_enterprise_organization.gh_org
github_enterprise_organization.gh_org: Creating...
2025-03-16T19:58:36.820Z [DEBUG] github_enterprise_organization.gh_org: applying the planned Create change
2025-03-16T19:58:38.636Z [INFO] provider.terraform-provider-github_v6.5.0: 2025/03/16 19:58:38 [DEBUG] Sleeping 1s between operations: timestamp=2025-03-16T19:58:38.636Z
Error: -16T19:58:39.713Z [ERROR] provider.terraform-provider-github_v6.5.0: Response contains error diagnostic: diagnostic_severity=ERROR tf_proto_version=5.6 tf_req_id=*** tf_rpc=ApplyResourceChange tf_provider_addr=provider tf_resource_type=github_enterprise_organization @caller=github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/internal/diag/diagnostics.go:58 @module=sdk.proto diagnostic_detail="" diagnostic_summary="PATCH https://api.github.com/orgs/***NEW_ORG_NAME***: 404 Not Found []" timestamp=2025-03-16T19:58:39.713Z
2025-03-16T19:58:39.716Z [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
Error: -16T19:58:39.716Z [ERROR] vertex "github_enterprise_organization.gh_org" error: PATCH https://api.github.com/orgs/***NEW_ORG_NAME***: 404 Not Found []

│ Error: PATCH https://api.github.com/orgs/***NEW_ORG_NAME***: 404 Not Found []

│ with github_enterprise_organization.gh_org,
│ on 1_main.tf line 56, in resource "github_enterprise_organization" "gh_org":
│ 56: resource "github_enterprise_organization" "gh_org" {


2025-03-16T19:58:39.719Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2025-03-16T19:58:39.721Z [INFO] provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/integrations/github/6.5.0/linux_amd64/terraform-provider-github_v6.5.0 id=3207
2025-03-16T19:58:39.721Z [DEBUG] provider: plugin exited
Error: Terraform exited with code 1.
Error: Process completed with exit code 1.
```

### Panic Output

```shell

```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.