Skip to content

404 error when creating files using github_repository_file resource #897

@kunalnanda

Description

@kunalnanda

Terraform Version

= v1.0.5

Affected Resource(s)

github_repository_file

Terraform Configuration Files

resource "github_repository" "repos" {
  for_each = local.repos

  name         = each.key
  description  = join("", [each.value.description, " - Managed by Terraform"])
  visibility   = each.value.visibility
  homepage_url = each.value.homepage_url
}

resource "github_repository_file" "gitignore" {
  for_each = local.repos

  content             = file("templates/.gitignore")
  file                = ".gitignore"
  repository          = github_repository.repos[each.key].name
  branch              = "main"
  overwrite_on_create = true
  commit_message      = "Managed by Terraform"
  commit_author       = "user"
  commit_email        = "user@email.com"
}

Expected Behavior

The repositories should be created, and a default .gitignore file should be created with contents from the given template file.

Actual Behavior

The repositories are created. The .gitignore file fails with the following error:

Error: unexpected status code: 404 Not Found

with github_repository_file.gitignore["terraform"],
on repos.tf line 10, in resource "github_repository_file" "gitignore":
10: resource "github_repository_file" "gitignore" {

This error is repeated 27 times, one for each repository.

Steps to Reproduce

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

  1. terraform apply

Important Factoids

I am running this against my personal Github account.
My Github token has the following permissions:

  • repo
    • repo:status
    • repo_deployment
    • public_repo
    • repo:invite
    • security_events

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    🔥 Backlog

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions