terraform-provider-github
terraform-provider-github copied to clipboard
[FEAT]: Unarchive if repository already exists
Describe the need
This is not a feature request just yet, but needs to be a discussion on what the behavior should be when we try to create a repository that already exists, in an archived state.
Current behavior for unarchived-but-existing repositories
The current behavior for unarchived-but-existing repositories is, we get a successful state update that the infrastructure matches configuration:
terraform {
required_providers {
github = {
source = "integrations/github"
version = "~> 5.0"
}
}
}
provider "github" {}
resource "github_repository" "example" {
name = "example"
description = "My awesome codebase"
visibility = "public"
archive_on_destroy = false
}
Output:
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│ - integrations/github in /Users/arun/go/bin
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published
│ releases.
╵
github_repository.example: Refreshing state... [id=archive]
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
Current behavior for archived-but-existing repositories
If the repository is archived, trying to recreate it fails:
terraform {
required_providers {
github = {
source = "integrations/github"
version = "~> 5.0"
}
}
}
provider "github" {}
resource "github_repository" "example" {
name = "archive"
description = "My awesome codebase"
visibility = "public"
archive_on_destroy = true
}
Upon deletion, which results in archiving:
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│ - integrations/github in /Users/arun/go/bin
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published
│ releases.
╵
github_repository.example: Destroying... [id=archive]
github_repository.example: Destruction complete after 1s
Apply complete! Resources: 0 added, 0 changed, 1 destroyed.
Upon recreation:
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│ - integrations/github in /Users/arun/go/bin
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published
│ releases.
╵
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# github_repository.example will be created
+ resource "github_repository" "example" {
+ allow_auto_merge = false
+ allow_merge_commit = true
+ allow_rebase_merge = true
+ allow_squash_merge = true
+ archive_on_destroy = true
+ archived = false
+ default_branch = (known after apply)
+ delete_branch_on_merge = false
+ description = "My awesome codebase"
+ etag = (known after apply)
+ full_name = (known after apply)
+ git_clone_url = (known after apply)
+ html_url = (known after apply)
+ http_clone_url = (known after apply)
+ id = (known after apply)
+ merge_commit_message = "PR_TITLE"
+ merge_commit_title = "MERGE_MESSAGE"
+ name = "archive"
+ node_id = (known after apply)
+ primary_language = (known after apply)
+ private = (known after apply)
+ repo_id = (known after apply)
+ squash_merge_commit_message = "COMMIT_MESSAGES"
+ squash_merge_commit_title = "COMMIT_OR_PR_TITLE"
+ ssh_clone_url = (known after apply)
+ svn_url = (known after apply)
+ topics = (known after apply)
+ visibility = "public"
+ web_commit_signoff_required = false
}
Plan: 1 to add, 0 to change, 0 to destroy.
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Saved the plan to: plan.tfplan
To perform exactly these actions, run the following command to apply:
terraform apply "plan.tfplan"
### 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
what the behavior should be when we try to create a repository that already exists, in an archived state.
Hmm...I'd probably try to match the API's behavior in this case. I think that means throwing some form of error.