Skip to content

[DOCS] Document how to handle Terraform config of vulnerability alerts when repo is archived #3369

Closed

Description

@dotnich-io

Expected Behavior

  1. Vulnerability alerts are automatically disabled
  2. Repository is archived

Actual Behavior

│ Error: repository $REDATCTED is archived, please remove the resource from your configuration
│
│   with module.github_repository_vulnerability_alerts.vulnerability_alerts[0],
│   on redacted.tf line 40, in resource "github_repository_vulnerability_alerts" "vulnerability_alerts":
│   40: resource "github_repository_vulnerability_alerts" "vulnerability_alerts" {
│

Terraform Version

Terraform v1.14.2
on darwin_arm64

  • provider registry.terraform.io/buildkite/buildkite v1.32.0
  • provider registry.terraform.io/hashicorp/aws v6.42.0
  • provider registry.terraform.io/hashicorp/github v6.11.1
  • provider registry.terraform.io/hashicorp/google v7.21.0
  • provider registry.terraform.io/integrations/github v6.12.0
  • provider registry.terraform.io/jianyuan/sentry v0.14.13
  • provider registry.terraform.io/newrelic/newrelic v3.85.0

Affected Resource(s)

  • github_repository
  • github_repository_vulnerability_alerts

Terraform Configuration Files

resource "github_repository" "project" {
  name        = var.project_name
  description = var.project_description
  visibility  = var.public_repo ? "public" : "private"
  archived    = var.archived
}

resource "github_repository_vulnerability_alerts" "vulnerability_alerts" {
  repository = github_repository.project.name
  enabled    = true
}

Steps to Reproduce

  1. Set archived = true on the github_repository resource
  2. Run terraform apply

Workarounds

I tried a couple workarounds. This one didn't work:

resource "github_repository_vulnerability_alerts" "vulnerability_alerts" {
  repository = github_repository.project.name
  enabled    = var.archived ? false : true
  depends_on = [github_repository.project]
}

But this did:

resource "github_repository_vulnerability_alerts" "vulnerability_alerts" {
  repository = github_repository.project.name
  enabled    = true
  count      = var.archived ? 0 : 1
  depends_on = [github_repository.project]
}

Other resources, such as github_branch_protection, handled the archival of the repository just fine.

Debug Output

Panic Output

Code of Conduct

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

Activity

  1. added
    Type: Bug
    Status: Triage
    on Apr 24, 2026
  2. github-actions commented on Apr 24, 2026

    @github-actions

    👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

  3. changed the title [-][BUG]: github_repository_vulnerability_alerts doesn't play nicely with archived repositories[/-] [+][BUG]: Archiving a `github_repository` doesn't cleanup `github_repository_vulnerability_alerts properly[/+] on Apr 24, 2026
  4. changed the title [-][BUG]: Archiving a `github_repository` doesn't cleanup `github_repository_vulnerability_alerts properly[/-] [+][BUG]: Archiving a `github_repository` doesn't cleanup `github_repository_vulnerability_alerts` properly[/+] on Apr 24, 2026
  5. dotnich-io commented on Apr 24, 2026

    @dotnich-io
    Author

    I did this in response to the deprecation notices introduced by #3038 / #3039.

  6. deiga commented on Apr 24, 2026

    @deiga
    Collaborator

    Thanks for raising this. It was an intentional decision that users will have to modify their config if a repo is archived.

    Otherwise your config keeps drifting away from the real state of things

  7. dotnich-io commented on Apr 24, 2026

    @dotnich-io
    Author

    @deiga thanks for the reply so quickly!

    It was an intentional decision

    That's great, but it's neither explicit nor consistent. github_branch_protection, which would also be obsolete in this circumstance, has no issue co-existing with a github_repository when archived = true.

    Could this be a validation error? Can we catch at the plan stage if a github_vulnerability_alerts attempts to have enabled = true when its repository resource has archived = true?

  8. deiga commented on Apr 24, 2026

    @deiga
    Collaborator

    @dotnich-io Yeah, we know that it's not consistent :/
    We're aiming that way!

    And it is plan time validation, but Terraform has no way to validate against other resources changes :(

    We will be deprecating the archive = true property in the future, so this will change in that regard 😬

  9. dotnich-io commented on Apr 24, 2026

    @dotnich-io
    Author

    @deiga roger that. May I request an update to the docs to let future users know how to handle this properly?

  10. deiga commented on Apr 25, 2026

    @deiga
    Collaborator

    @dotnich-io That's a very reasonable request, yes :)

    Could you change the title of the issue to be something like "[DOCS] Document how to handle Terraform config of vulnerability alerts when repo is archived"?

  11. added
    Type: Documentation
    and removed
    Type: Bug
    Status: Triage
    on Apr 25, 2026
  12. added theissue type on Apr 25, 2026
  13. changed the title [-][BUG]: Archiving a `github_repository` doesn't cleanup `github_repository_vulnerability_alerts` properly[/-] [+][DOCS] Document how to handle Terraform config of vulnerability alerts when repo is archived[/+] on Jul 5, 2026
  14. added a commit that references this issue on Jul 23, 2026
    32b0152
  15. added a commit that references this issue on Aug 4, 2026
    9f7ffe2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: Documentationr/repositoryvNext

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions