integrations / terraform-provider-github

Terraform GitHub provider
https://www.terraform.io/docs/providers/github/
MIT License
904 stars 743 forks source link

[FEAT]: manage existing repositories #1878

Open benkeil opened 1 year ago

benkeil commented 1 year ago

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

kfcampbell commented 1 year ago

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?

benkeil commented 1 year ago

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.

felixlut commented 1 year ago

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

github-actions[bot] commented 3 months ago

👋 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!

staffanf commented 3 months ago

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