Skip to content

Repository environment creation error #1262

@AlessandroLorenzi

Description

@AlessandroLorenzi

Terraform Version

  • Terraform v1.0.7

Affected Resource(s)

  • github_repository_environment

Terraform Configuration Files

resource "github_repository_environment" "my_repo_environments" {
  for_each = toset([
    "production",
    "staging",
  ])

  repository       = github_repository.my_repo.name
  environment      = each.key

}

Debug Output

Expected Behavior

Create an environment

Actual Behavior

Got this errore (both staging and production)

╷
│ Error: PUT https://api.github.com/repos/my-org/my-repo/environments/production: 422 Fail to create protected rule, please ensure billing plan include protected branch gate. []
│ 

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Work arround

If I set the "Deployment branches" in the GUI (protected branches), import the resource and add the following config terraform terminates well.

  deployment_branch_policy {
    protected_branches = true
    custom_branch_policies = false
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Up for grabsIssues that are ready to be worked on by anyoneType: BugSomething isn't working as documented

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions