Skip to content

Conversation

hminaee-tc
Copy link

@hminaee-tc hminaee-tc commented Apr 17, 2025

Resolves

integrations#2632


Summary of Changes

Before the change?

  • Forking repos using terraform is not possible

After the change?

I've added support for forking GitHub repositories to the GitHub Terraform Provider. This feature allows users to fork existing repositories using Terraform, supporting both user and organization accounts.

Key Implementations:

  1. Fork Parameters: Added schema attributes for repository forking:

    • fork: Boolean flag to enable forking
    • source_owner: Owner of the repository to fork from
    • source_repo: Name of the repository to fork from
  2. Fork Creation Logic: Implemented forking in the resourceGithubRepositoryCreate function:

  • Added a new branch to the existing conditional structure to handle forks
  • Supports custom repository naming via the name attribute
  • Properly handles organization-owned forks by setting the organization parameter
  1. Asynchronous Fork Handling: Added support for GitHub's asynchronous fork creation:
  • Properly handles the 202 Accepted response
  • Includes error logging and validation of returned data
  1. State Management: Set repository attributes in Terraform state:
  • Repository name, full name, and various URL formats
  • All critical attributes needed for Terraform to track the resource
  1. Fork Information Reading: Enhanced resourceGithubRepositoryRead to read fork status:
  • Detects when a repository is a fork
  • Sets the source repository information in state
  • Properly clears fork information for non-forked repositories

Here are few tests/show case for different aspect of the above changes

  • Forking the repos successfully works
    creating fork and also fork from fork:
terraform {
  required_providers {
    github = {
      source  = "integrations/github"
    }
  }
}

provider "github" {
  owner = "TucowsTCX"  # Your organization
  token = "ghp_xxxxx"
}

# Test forking a repository
resource "github_repository" "forked_repo" {
  name         = "test-fork-terraform"
  description  = "Test fork functionality with custom provider"
  fork         = true
  source_owner = "TucowsTCX" 
  source_repo  = "test-deleted"
}

# Second fork (forking from the first fork using a reference)
resource "github_repository" "second_fork" {
  name         = "test-fork-terraform-second"
  description  = "Second fork created from the first fork"
  fork         = true
  source_owner = "TucowsTCX" 
  # Reference the name attribute of the first fork
  source_repo  = github_repository.forked_repo.name
  
  depends_on = [github_repository.forked_repo]
}

Note you can also use : export GITHUB_TOKEN="gh_xxx"

terraform init

terraform init    

Initializing the backend...

Initializing provider plugins...
- Reusing previous version of integrations/github from the dependency lock file
- Using previously-installed integrations/github v6.6.0

╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - integrations/github in /Users/hamed/Desktop/tucows-code/terra-providor-extended/terraform-provider-github
│ 
│ Skip terraform init when using provider development overrides. It is not necessary
│ and may error unexpectedly.
╵

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

terraform plan

here is the plan result:

#1 (comment)

terraform apply

here is the apply result:

#1 (comment)

Also importing existing resources :

Now lets say we forked a repo manually and now we need to import it in terraform so it is being tracked

first fork a repo called manual-test

import {
  # The provider-specific resource address
  to = github_repository.test_import
  
  # The existing resource identifier 
  id = "hamed-test"
}

# Resource to import an existing forked repository
resource "github_repository" "test_import" {
  name = "hamed-test"
  # Minimal configuration only - import will fill in the rest
}

And the result shows
#1 (comment)

verify the import:

#1 (comment)

Now time to destroy it which means it should also be able to destroy manually created fork


terraform destroy
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - integrations/github in /Users/hamed/Desktop/tucows-code/terra-providor-extended/terraform-provider-github
│ 
│ 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.forked_repo: Refreshing state... [id=test-fork-terraform]
github_repository.second_fork: Refreshing state... [id=test-fork-terraform-second]

Terraform used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
  - destroy

Terraform will perform the following actions:

  # github_repository.forked_repo will be destroyed
  - resource "github_repository" "forked_repo" {
      - allow_auto_merge            = false -> null
      - allow_merge_commit          = true -> null
      - allow_rebase_merge          = true -> null
      - allow_squash_merge          = true -> null
      - allow_update_branch         = false -> null
      - archived                    = false -> null
      - default_branch              = "main" -> null
      - delete_branch_on_merge      = false -> null
      - description                 = "UPDATED: Test fork functionality with custom provider" -> null
      - etag                        = "W/\"9ad77049741f2d57f3dcfb1f19a44cff0287228118b99de9b7e63af2cf3b6f97\"" -> null
      - fork                        = true -> null
      - full_name                   = "TucowsTCX/test-fork-terraform" -> null
      - git_clone_url               = "git://github.com/TucowsTCX/test-fork-terraform.git" -> null
      - has_discussions             = false -> null
      - has_downloads               = false -> null
      - has_issues                  = false -> null
      - has_projects                = false -> null
      - has_wiki                    = false -> null
      - homepage_url                = "https://example.com" -> null
      - html_url                    = "https://github.com/TucowsTCX/test-fork-terraform" -> null
      - http_clone_url              = "https://github.com/TucowsTCX/test-fork-terraform.git" -> null
      - id                          = "test-fork-terraform" -> null
      - is_template                 = false -> null
      - merge_commit_message        = "PR_TITLE" -> null
      - merge_commit_title          = "MERGE_MESSAGE" -> null
      - name                        = "test-fork-terraform" -> null
      - node_id                     = "R_kgDOOtfkKw" -> null
      - private                     = false -> null
      - repo_id                     = 987227179 -> null
      - source_owner                = "TucowsTCX" -> null
      - source_repo                 = "test-deleted" -> null
      - squash_merge_commit_message = "COMMIT_MESSAGES" -> null
      - squash_merge_commit_title   = "COMMIT_OR_PR_TITLE" -> null
      - ssh_clone_url               = "[email protected]:TucowsTCX/test-fork-terraform.git" -> null
      - svn_url                     = "https://github.com/TucowsTCX/test-fork-terraform" -> null
      - topics                      = [] -> null
      - visibility                  = "public" -> null
      - vulnerability_alerts        = false -> null
      - web_commit_signoff_required = false -> null

      - security_and_analysis {
          - secret_scanning {
              - status = "disabled" -> null
            }
          - secret_scanning_push_protection {
              - status = "disabled" -> null
            }
        }
    }

  # github_repository.second_fork will be destroyed
  - resource "github_repository" "second_fork" {
      - allow_auto_merge            = false -> null
      - allow_merge_commit          = true -> null
      - allow_rebase_merge          = true -> null
      - allow_squash_merge          = true -> null
      - allow_update_branch         = false -> null
      - archived                    = false -> null
      - default_branch              = "main" -> null
      - delete_branch_on_merge      = false -> null
      - description                 = "Second fork created from the first fork" -> null
      - etag                        = "W/\"7e1c2db83427f2f42371d7532deb87f1126e31e86f0d12ae4b1c8f4d0e1a3fde\"" -> null
      - fork                        = true -> null
      - full_name                   = "TucowsTCX/test-fork-terraform-second" -> null
      - git_clone_url               = "git://github.com/TucowsTCX/test-fork-terraform-second.git" -> null
      - has_discussions             = false -> null
      - has_downloads               = false -> null
      - has_issues                  = false -> null
      - has_projects                = false -> null
      - has_wiki                    = false -> null
      - html_url                    = "https://github.com/TucowsTCX/test-fork-terraform-second" -> null
      - http_clone_url              = "https://github.com/TucowsTCX/test-fork-terraform-second.git" -> null
      - id                          = "test-fork-terraform-second" -> null
      - is_template                 = false -> null
      - merge_commit_message        = "PR_TITLE" -> null
      - merge_commit_title          = "MERGE_MESSAGE" -> null
      - name                        = "test-fork-terraform-second" -> null
      - node_id                     = "R_kgDOOtfkTQ" -> null
      - private                     = false -> null
      - repo_id                     = 987227213 -> null
      - source_owner                = "TucowsTCX" -> null
      - source_repo                 = "test-fork-terraform" -> null
      - squash_merge_commit_message = "COMMIT_MESSAGES" -> null
      - squash_merge_commit_title   = "COMMIT_OR_PR_TITLE" -> null
      - ssh_clone_url               = "[email protected]:TucowsTCX/test-fork-terraform-second.git" -> null
      - svn_url                     = "https://github.com/TucowsTCX/test-fork-terraform-second" -> null
      - topics                      = [] -> null
      - visibility                  = "public" -> null
      - vulnerability_alerts        = false -> null
      - web_commit_signoff_required = false -> null

      - security_and_analysis {
          - secret_scanning {
              - status = "disabled" -> null
            }
          - secret_scanning_push_protection {
              - status = "disabled" -> null
            }
        }
    }

Plan: 0 to add, 0 to change, 2 to destroy.

Changes to Outputs:
  - fork_full_name        = "TucowsTCX/test-fork-terraform" -> null
  - fork_name             = "test-fork-terraform" -> null
  - fork_url              = "https://github.com/TucowsTCX/test-fork-terraform" -> null
  - second_fork_full_name = "TucowsTCX/test-fork-terraform-second" -> null
  - second_fork_name      = "test-fork-terraform-second" -> null
  - second_fork_url       = "https://github.com/TucowsTCX/test-fork-terraform-second" -> null

Do you really want to destroy all resources?
  Terraform will destroy all your managed infrastructure, as shown above.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value: yes

github_repository.second_fork: Destroying... [id=test-fork-terraform-second]
github_repository.second_fork: Destruction complete after 0s
github_repository.forked_repo: Destroying... [id=test-fork-terraform]
github_repository.forked_repo: Destruction complete after 2s

Destroy complete! Resources: 2 destroyed.

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

extra dev notes (if you are running test directly in GO code):

export GITHUB_OWNER=ORG_NAME
export GITHUB_TOKEN=ghp_TOKEN
export TF_ACC=1
go build -o terraform-provider-github
image

@hminaee-tc
Copy link
Author

Testing import

terraform plan 
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - integrations/github in /Users/hamed/Desktop/tucows-code/terra-providor-extended/terraform-provider-github
│ 
│ 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.test_import: Preparing import... [id=manual-test]
github_repository.test_import: Refreshing state... [id=manual-test]
github_repository.forked_repo: Refreshing state... [id=test-fork-terraform]
github_repository.second_fork: Refreshing state... [id=test-fork-terraform-second]

Terraform used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # github_repository.test_import will be updated in-place
  # (imported from "manual-test")
  ~ resource "github_repository" "test_import" {
        allow_auto_merge            = false
        allow_merge_commit          = true
        allow_rebase_merge          = true
        allow_squash_merge          = true
        allow_update_branch         = false
        archived                    = false
        auto_init                   = false
        default_branch              = "main"
        delete_branch_on_merge      = false
      - description                 = "Second fork created from the first fork" -> null
        etag                        = "W/\"0a7b415bd20ca247f5c96fcf5f8d092ab50998eb39a6b4bc0b77275a9c4fb614\""
      - fork                        = true -> null
        full_name                   = "TucowsTCX/manual-test"
        git_clone_url               = "git://github.com/TucowsTCX/manual-test.git"
        has_discussions             = false
      - has_downloads               = true -> null
        has_issues                  = false
      - has_projects                = true -> null
        has_wiki                    = false
        html_url                    = "https://github.com/TucowsTCX/manual-test"
        http_clone_url              = "https://github.com/TucowsTCX/manual-test.git"
        id                          = "manual-test"
        is_template                 = false
        merge_commit_message        = "PR_TITLE"
        merge_commit_title          = "MERGE_MESSAGE"
        name                        = "manual-test"
        node_id                     = "R_kgDOOp9MTQ"
        private                     = false
        repo_id                     = 983518285
      - source_owner                = "TucowsTCX" -> null
      - source_repo                 = "test-fork-terraform-second" -> null
        squash_merge_commit_message = "COMMIT_MESSAGES"
        squash_merge_commit_title   = "COMMIT_OR_PR_TITLE"
        ssh_clone_url               = "[email protected]:TucowsTCX/manual-test.git"
        svn_url                     = "https://github.com/TucowsTCX/manual-test"
        topics                      = []
        visibility                  = "public"
        vulnerability_alerts        = false
        web_commit_signoff_required = false

        security_and_analysis {
            secret_scanning {
                status = "disabled"
            }
            secret_scanning_push_protection {
                status = "disabled"
            }
        }
    }

Plan: 1 to import, 0 to add, 1 to change, 0 to destroy.

─────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee
to take exactly these actions if you run "terraform apply" now.
(3.11.9) hamed@K99V0GWM7R-MacBook-Pro terraform-fork % terraform apply
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - integrations/github in /Users/hamed/Desktop/tucows-code/terra-providor-extended/terraform-provider-github
│ 
│ 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.test_import: Preparing import... [id=manual-test]
github_repository.test_import: Refreshing state... [id=manual-test]
github_repository.forked_repo: Refreshing state... [id=test-fork-terraform]
github_repository.second_fork: Refreshing state... [id=test-fork-terraform-second]

Terraform used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # github_repository.test_import will be updated in-place
  # (imported from "manual-test")
  ~ resource "github_repository" "test_import" {
        allow_auto_merge            = false
        allow_merge_commit          = true
        allow_rebase_merge          = true
        allow_squash_merge          = true
        allow_update_branch         = false
        archived                    = false
        auto_init                   = false
        default_branch              = "main"
        delete_branch_on_merge      = false
      - description                 = "Second fork created from the first fork" -> null
        etag                        = "W/\"0a7b415bd20ca247f5c96fcf5f8d092ab50998eb39a6b4bc0b77275a9c4fb614\""
      - fork                        = true -> null
        full_name                   = "TucowsTCX/manual-test"
        git_clone_url               = "git://github.com/TucowsTCX/manual-test.git"
        has_discussions             = false
      - has_downloads               = true -> null
        has_issues                  = false
      - has_projects                = true -> null
        has_wiki                    = false
        html_url                    = "https://github.com/TucowsTCX/manual-test"
        http_clone_url              = "https://github.com/TucowsTCX/manual-test.git"
        id                          = "manual-test"
        is_template                 = false
        merge_commit_message        = "PR_TITLE"
        merge_commit_title          = "MERGE_MESSAGE"
        name                        = "manual-test"
        node_id                     = "R_kgDOOp9MTQ"
        private                     = false
        repo_id                     = 983518285
      - source_owner                = "TucowsTCX" -> null
      - source_repo                 = "test-fork-terraform-second" -> null
        squash_merge_commit_message = "COMMIT_MESSAGES"
        squash_merge_commit_title   = "COMMIT_OR_PR_TITLE"
        ssh_clone_url               = "[email protected]:TucowsTCX/manual-test.git"
        svn_url                     = "https://github.com/TucowsTCX/manual-test"
        topics                      = []
        visibility                  = "public"
        vulnerability_alerts        = false
        web_commit_signoff_required = false

        security_and_analysis {
            secret_scanning {
                status = "disabled"
            }
            secret_scanning_push_protection {
                status = "disabled"
            }
        }
    }

Plan: 1 to import, 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

github_repository.test_import: Importing... [id=manual-test]
github_repository.test_import: Import complete [id=manual-test]
github_repository.test_import: Modifying... [id=manual-test]
github_repository.test_import: Modifications complete after 2s [id=manual-test]

Apply complete! Resources: 1 imported, 0 added, 1 changed, 0 destroyed.

Outputs:

fork_full_name = "TucowsTCX/test-fork-terraform"
fork_name = "test-fork-terraform"
fork_url = "https://github.com/TucowsTCX/test-fork-terraform"
second_fork_full_name = "TucowsTCX/test-fork-terraform-second"
second_fork_name = "test-fork-terraform-second"
second_fork_url = "https://github.com/TucowsTCX/test-fork-terraform-second"

@hminaee-tc
Copy link
Author

Verify test import


terraform state show github_repository.test_import
# github_repository.test_import:
resource "github_repository" "test_import" {
    allow_auto_merge            = false
    allow_merge_commit          = true
    allow_rebase_merge          = true
    allow_squash_merge          = true
    allow_update_branch         = false
    archived                    = false
    auto_init                   = false
    default_branch              = "main"
    delete_branch_on_merge      = false
    etag                        = "W/\"a49e0725b69077d79d67672184cb85f597f133bd77fed8b87e7e2175f8bdee48\""
    fork                        = true
    full_name                   = "TucowsTCX/manual-test"
    git_clone_url               = "git://github.com/TucowsTCX/manual-test.git"
    has_discussions             = false
    has_downloads               = false
    has_issues                  = false
    has_projects                = false
    has_wiki                    = false
    html_url                    = "https://github.com/TucowsTCX/manual-test"
    http_clone_url              = "https://github.com/TucowsTCX/manual-test.git"
    id                          = "manual-test"
    is_template                 = false
    merge_commit_message        = "PR_TITLE"
    merge_commit_title          = "MERGE_MESSAGE"
    name                        = "manual-test"
    node_id                     = "R_kgDOOp9MTQ"
    private                     = false
    repo_id                     = 983518285
    source_owner                = "TucowsTCX"
    source_repo                 = "test-fork-terraform-second"
    squash_merge_commit_message = "COMMIT_MESSAGES"
    squash_merge_commit_title   = "COMMIT_OR_PR_TITLE"
    ssh_clone_url               = "[email protected]:TucowsTCX/manual-test.git"
    svn_url                     = "https://github.com/TucowsTCX/manual-test"
    topics                      = []
    visibility                  = "public"
    vulnerability_alerts        = false
    web_commit_signoff_required = false

    security_and_analysis {
        secret_scanning {
            status = "disabled"
        }
        secret_scanning_push_protection {
            status = "disabled"
        }
    }
}
(3.11.9) hamed@K99V0GWM7R-MacBook-Pro terraform-fork % terraform state list
github_repository.forked_repo
github_repository.second_fork
github_repository.test_import

@hminaee-tc
Copy link
Author

plan result

terraform plan 
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - integrations/github in /Users/hamed/Desktop/tucows-code/terra-providor-extended/terraform-provider-github
│ 
│ 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.forked_repo will be created
  + resource "github_repository" "forked_repo" {
      + allow_auto_merge            = false
      + allow_merge_commit          = true
      + allow_rebase_merge          = true
      + allow_squash_merge          = true
      + archived                    = false
      + default_branch              = (known after apply)
      + delete_branch_on_merge      = false
      + description                 = "Test fork functionality with custom provider"
      + etag                        = (known after apply)
      + fork                        = true
      + 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                        = "test-fork-terraform"
      + node_id                     = (known after apply)
      + primary_language            = (known after apply)
      + private                     = (known after apply)
      + repo_id                     = (known after apply)
      + source_owner                = "TucowsTCX"
      + source_repo                 = "test-deleted"
      + 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                  = (known after apply)
      + web_commit_signoff_required = false
    }

  # github_repository.second_fork will be created
  + resource "github_repository" "second_fork" {
      + allow_auto_merge            = false
      + allow_merge_commit          = true
      + allow_rebase_merge          = true
      + allow_squash_merge          = true
      + archived                    = false
      + default_branch              = (known after apply)
      + delete_branch_on_merge      = false
      + description                 = "Second fork created from the first fork"
      + etag                        = (known after apply)
      + fork                        = true
      + 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                        = "test-fork-terraform-second"
      + node_id                     = (known after apply)
      + primary_language            = (known after apply)
      + private                     = (known after apply)
      + repo_id                     = (known after apply)
      + source_owner                = "TucowsTCX"
      + source_repo                 = "test-fork-terraform"
      + 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                  = (known after apply)
      + web_commit_signoff_required = false
    }

Plan: 2 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + fork_full_name        = (known after apply)
  + fork_name             = "test-fork-terraform"
  + fork_url              = (known after apply)
  + second_fork_full_name = (known after apply)
  + second_fork_name      = "test-fork-terraform-second"
  + second_fork_url       = (known after apply)

─────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee
to take exactly these actions if you run "terraform apply" now.

@hminaee-tc
Copy link
Author

apply result

terraform apply
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - integrations/github in /Users/hamed/Desktop/tucows-code/terra-providor-extended/terraform-provider-github
│ 
│ 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.forked_repo will be created
  + resource "github_repository" "forked_repo" {
      + allow_auto_merge            = false
      + allow_merge_commit          = true
      + allow_rebase_merge          = true
      + allow_squash_merge          = true
      + archived                    = false
      + default_branch              = (known after apply)
      + delete_branch_on_merge      = false
      + description                 = "Test fork functionality with custom provider"
      + etag                        = (known after apply)
      + fork                        = true
      + 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                        = "test-fork-terraform"
      + node_id                     = (known after apply)
      + primary_language            = (known after apply)
      + private                     = (known after apply)
      + repo_id                     = (known after apply)
      + source_owner                = "TucowsTCX"
      + source_repo                 = "test-deleted"
      + 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                  = (known after apply)
      + web_commit_signoff_required = false
    }

  # github_repository.second_fork will be created
  + resource "github_repository" "second_fork" {
      + allow_auto_merge            = false
      + allow_merge_commit          = true
      + allow_rebase_merge          = true
      + allow_squash_merge          = true
      + archived                    = false
      + default_branch              = (known after apply)
      + delete_branch_on_merge      = false
      + description                 = "Second fork created from the first fork"
      + etag                        = (known after apply)
      + fork                        = true
      + 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                        = "test-fork-terraform-second"
      + node_id                     = (known after apply)
      + primary_language            = (known after apply)
      + private                     = (known after apply)
      + repo_id                     = (known after apply)
      + source_owner                = "TucowsTCX"
      + source_repo                 = "test-fork-terraform"
      + 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                  = (known after apply)
      + web_commit_signoff_required = false
    }

Plan: 2 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + fork_full_name        = (known after apply)
  + fork_name             = "test-fork-terraform"
  + fork_url              = (known after apply)
  + second_fork_full_name = (known after apply)
  + second_fork_name      = "test-fork-terraform-second"
  + second_fork_url       = (known after apply)

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

github_repository.forked_repo: Creating...
github_repository.forked_repo: Creation complete after 4s [id=test-fork-terraform]
github_repository.second_fork: Creating...
github_repository.second_fork: Creation complete after 4s [id=test-fork-terraform-second]

Apply complete! Resources: 2 added, 0 changed, 0 destroyed.

Outputs:

fork_full_name = "TucowsTCX/test-fork-terraform"
fork_name = "test-fork-terraform"
fork_url = "https://github.com/TucowsTCX/test-fork-terraform"
second_fork_full_name = "TucowsTCX/test-fork-terraform-second"
second_fork_name = "test-fork-terraform-second"
second_fork_url = "https://github.com/TucowsTCX/test-fork-terraform-second"


@hminaee-tc hminaee-tc requested a review from aosagie-tc May 22, 2025 13:21
Copy link
Collaborator

@aosagie-tc aosagie-tc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled this down and did some local testing. Import, delete and apply works good. so does plan.

Copy link
Collaborator

@aosagie-tc aosagie-tc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled this down and did some local testing. Import, delete and apply works good. so does plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants