integrations / integrations/terraform-provider-github
[BUG]: github_enterprise_organization resource does not support GitHub App authentication
- Dominant language
- Go
- Stars
- 1.2k
- Forks
- 1k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 8
Description
### Expected Behavior
The resource should work with GitHub App authentication when the app has the required enterprise permissions, similar to how other organization-level resources work with GitHub Apps.
### Actual Behavior
The github_enterprise_organization resource fails with "Resource not accessible by integration" error when using GitHub App authentication, even when the app has all required enterprise-level permissions.
What exactly happened is I used a PAT before to handle this org with tf and did not had a problem. then I switch to a github app and issue appear.
I also tried to remove the resource from my tfstate and reimport it using the github app credentials but I have the following errors:
terraform import module.enterprise_organization.github_enterprise_organization.this my-enterprise/my-org
module.enterprise_organization.github_enterprise_organization.this: Importing from ID "my-enterprise/my-org"...
╷
│ Error: Resource not accessible by integration
After giving rea&write to Enterprise people on enterprise permission it then say:
terraform import module.enterprise_organization.github_enterprise_organization.this my-enterprise/my-org
module.enterprise_organization.github_enterprise_organization.this: Importing from ID "my-enterprise/my-org"...
╷
│ Error: Your token has not been granted the required scopes to execute this query. The 'id' field requires one of the following scopes: ['read:enterprise'], but your token has only been granted the: ['admin:org', 'gist', 'repo', 'workflow'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
│
### Terraform Version
Terraform Version: 1.14.3
Provider Version: 6.10.2
### Affected Resource(s)
github_enterprise_organization
### Terraform Configuration Files
```hcl
I tried to use 2 provider (one for entreprise level one for org level)
# Default provider for org-level resources
provider "github" {
owner = "xxx-org"
app_auth {
id = "xxxx"
installation_id = "xxxx" # Org installation ID
pem_file = file("private-key.pem")
}
}
# Enterprise provider with separate installation ID
provider "github" {
alias = "enterprise"
owner = "xxxxx-enterprise"
app_auth {
id = "xxxxx"
installation_id = "xxxxx" # Enterprise installation ID
pem_file = file("private-key.pem")
}
}
# Module using enterprise provider
module "enterprise_organization" {
source = "./modules/enterprise-organization"
providers = {
github = github
github.enterprise = github.enterprise
}
enterprise_id = "xxxxx
name = "xxxx"
# ...
}
# modules/enterprise-organization/organization.tf
resource "github_enterprise_organization" "this" {
provider = github.enterprise # Uses enterprise installation ID
enterprise_id = var.enterprise_id
name = var.name
billing_email = var.billing_email
admin_logins = toset(var.admin_logins)
}
```
### Steps to Reproduce
Create a GitHub App with enterprise-level administration permissions
Install the app at enterprise level and org level (get enterprise installation ID)
Configure Terraform provider with app_auth using enterprise installation ID
Attempt to import github_enterprise_organization resource
Error occurs: "Resource not accessible by integration"
### Debug Output
```shell
```
### Panic Output
```shell
```
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Contributor guide
Assessment
This issue has not been assessed yet.