integrations / integrations/terraform-provider-github

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

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

Description

### 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 https://github.com/integrations/terraform-provider-github/issues/2383 ?

Also tried re-running the Terraform plan/apply based on comments in https://github.com/integrations/terraform-provider-github/issues/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

```hcl
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

```shell

```

### 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.