Expected Behavior
When a GitHub App node ID is included in dismissal_restrictions of github_branch_protection, the provider should be able to read and manage the branch protection rule, including setting app node IDs alongside team node IDs.
Actual Behavior
The provider fails with Resource not accessible by integration during both plan and apply when:
- An app node ID is specified in
dismissal_restrictions in the HCL config, OR
- An app has been added to
dismissal_restrictions via the GitHub API externally (state refresh fails)
This makes it impossible to use Terraform to manage branch protection rules that include GitHub Apps in dismissal restrictions.
Terraform Version
Terraform v1.6.0
+ provider registry.terraform.io/integrations/github v6.x
Affected Resource(s)
Terraform Configuration Files
data "github_team" "maintainers" {
for_each = {
for team in var.teams : team.team_slug => team
if team.role == "maintain" || team.role == "admin"
}
slug = each.key
}
resource "github_branch_protection" "this" {
for_each = toset(var.protected_branches)
repository_id = github_repository.this.node_id
pattern = each.value
required_pull_request_reviews {
dismiss_stale_reviews = false
require_code_owner_reviews = true
required_approving_review_count = 1
restrict_dismissals = true
dismissal_restrictions = concat(
[for team_data in data.github_team.maintainers : team_data.node_id],
["A_kwPOAAELEM4AECna"] # GitHub App node ID
)
}
enforce_admins = false
}
Steps to Reproduce
- Create a
github_branch_protection resource with restrict_dismissals = true
- Include a GitHub App node ID in
dismissal_restrictions alongside team node IDs
- Run
terraform plan or terraform apply
Alternative reproduction:
- Have a working
github_branch_protection with only team node IDs in dismissal_restrictions
- Externally add a GitHub App to
dismissal_restrictions via the GitHub REST API:
PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews
{ "dismissal_restrictions": { "teams": [...], "apps": ["my-app-slug"] } }
- Run
terraform plan — fails during state refresh
Error Output
Error: Resource not accessible by integration
with github_branch_protection.this["main"],
on repo.tf line 158, in resource "github_branch_protection" "this":
158: resource "github_branch_protection" "this" {
Additional Context
- The GitHub REST API supports apps in
dismissal_restrictions and works correctly with user PATs
- The GitHub App used by the Terraform provider has
administration:write permission on the org
- The error occurs even when the app node ID in
dismissal_restrictions belongs to a different (non-Terraform) app that is installed on the repository
- This appears to be a provider-level limitation where the GraphQL mutation used for branch protection rules doesn't support app actors in
dismissalRestrictionsActorIds, or the provider doesn't properly translate app node IDs for the mutation
Workaround
Currently the only workaround is to manage the app entry in dismissal_restrictions via the GitHub REST API outside of Terraform, and ensure Terraform never touches repos where an app has been added. This is fragile and creates state drift.
Expected Behavior
When a GitHub App node ID is included in
dismissal_restrictionsofgithub_branch_protection, the provider should be able to read and manage the branch protection rule, including setting app node IDs alongside team node IDs.Actual Behavior
The provider fails with
Resource not accessible by integrationduring both plan and apply when:dismissal_restrictionsin the HCL config, ORdismissal_restrictionsvia the GitHub API externally (state refresh fails)This makes it impossible to use Terraform to manage branch protection rules that include GitHub Apps in dismissal restrictions.
Terraform Version
Affected Resource(s)
github_branch_protectionTerraform Configuration Files
Steps to Reproduce
github_branch_protectionresource withrestrict_dismissals = truedismissal_restrictionsalongside team node IDsterraform planorterraform applyAlternative reproduction:
github_branch_protectionwith only team node IDs indismissal_restrictionsdismissal_restrictionsvia the GitHub REST API:terraform plan— fails during state refreshError Output
Additional Context
dismissal_restrictionsand works correctly with user PATsadministration:writepermission on the orgdismissal_restrictionsbelongs to a different (non-Terraform) app that is installed on the repositorydismissalRestrictionsActorIds, or the provider doesn't properly translate app node IDs for the mutationWorkaround
Currently the only workaround is to manage the app entry in
dismissal_restrictionsvia the GitHub REST API outside of Terraform, and ensure Terraform never touches repos where an app has been added. This is fragile and creates state drift.