terraform-provider-github icon indicating copy to clipboard operation
terraform-provider-github copied to clipboard

[FEAT]: manage existing repositories

Open benkeil opened this issue 2 years ago β€’ 5 comments

Describe the need

It is a common use case that the repository already exists and I want to manage it.

Our company has ~5000 repositories, I will not write scripts to import them.

Would it be feasible to split all the features from the resource github_repository out? So I can use data github_repository to reference the existing repo and use something like resource github_repository_configuration_security_and_analysis to manage the security_and_analysis property of the repository?

Example:

data "github_repository" "example" {
  full_name = "hashicorp/terraform"
}

resource "github_repository_configuration_security_and_analysis" {
  repository = data.github_repository.example.id
  advanced_security = {
    status = "enabled"
  }
  ...
}

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

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

benkeil avatar Sep 07 '23 06:09 benkeil

Hmm...in theory, that's an attractive proposition to provide as our repo resource is pretty bloated. Completely replacing that resource would be such a breaking change that I think it's a non-starter. That functionality could be added in a non-exclusive way, perhaps.

Specifically with regard to existing repos, have you tried to import these repositories so they're managed by Terraform?

kfcampbell avatar Sep 08 '23 18:09 kfcampbell

The repository resource could also stay as it is. And there are 2 ways to configure the repo.

import does not work for my case. The state don’t even exists. I use terraform cdk to read a dynamic configuration.

benkeil avatar Sep 08 '23 18:09 benkeil

This is definitely possible, I managed to make it work for GitHub repository topics in #1845

felixlut avatar Oct 23 '23 05:10 felixlut

πŸ‘‹ Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

github-actions[bot] avatar Jul 20 '24 01:07 github-actions[bot]

This is a very relevant issue and I feel it deserves to be kept open

staffanf avatar Jul 25 '24 22:07 staffanf

πŸ‘‹ Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

github-actions[bot] avatar Apr 22 '25 02:04 github-actions[bot]

This is a very relevant issue and I feel it deserves to be kept open

☝

renefritze avatar Apr 22 '25 06:04 renefritze