Skip to content

[BUG]: Fails to create github_repository fork with Github Advanced Security and Secret scanning enabled #3010

@jrbeilke

Description

@jrbeilke

Expected Behavior

Attempting to create a new github_repository as a fork with Github Advanced Security and Secret scanning enabled

Actual Behavior

Attempted to create a new github_repository as a fork, but the apply failed with an error related to Github Advanced Security and Secret scanning

Error:

Error: PATCH https://api.github.com/repos/jrbeilke/test-fork: 422 Secret scanning can only be enabled on repos where Advanced Security is enabled. []
with module.github_repos["test-fork"].github_repository.fork_repo
on ../modules/fork_repo/main.tf line 10, in resource "github_repository" "fork_repo":
resource "github_repository" "fork_repo" {

Possibly related to #2383 ?

Also tried re-running the Terraform plan/apply based on comments in #2145
but the Github repository was actually created during the first apply, and wasn't fully provisioned or persisted to the tfstate, so the retry fails.

422 Could not clone: Name already exists on this account

Terraform Version

Terraform v1.13.0
on linux_amd64

  • provider registry.terraform.io/integrations/github v6.9.0

Affected Resource(s)

  • github_repository

Terraform Configuration Files

resource "github_repository" "fork_repo" {
  name        = var.repo_name
  description = var.repo_description
  visibility  = "private"

  archive_on_destroy     = true
  delete_branch_on_merge = true

  # Add vulnerability alerts for all repositories
  vulnerability_alerts = true

  security_and_analysis {
    advanced_security {
      status = "enabled"
    }
    secret_scanning {
      status = "enabled"
    }
    secret_scanning_push_protection {
      status = "enabled"
    }
  }

  # Create repo by forking a source Github repo
  fork         = var.fork
  source_owner = var.source_owner
  source_repo  = var.source_repo

Steps to Reproduce

$ terraform apply

Debug Output

Panic Output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageThis is being looked at and prioritizedType: 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