Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from Terraform to OpenTofu #104

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

davidtabat
Copy link

As part of this PR, I renamed the terraform repository to opentofu in variables.tf for consistency.

Please ensure the repository on GitHub is renamed from terraform to opentofu before merging this PR. Otherwise, merging will trigger the creation of a new repository named opentofu.

If you don't want renaming the repository, let me know, and I will revert the name in variables.tf.

@davidtabat davidtabat requested a review from a team as a code owner January 11, 2025 02:55
@davidtabat davidtabat mentioned this pull request Jan 11, 2025
Copy link
Contributor

@sprankhub sprankhub left a comment

Choose a reason for hiding this comment

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

First, thanks a lot for your PR!

This looks too simple to be true 😂 Did you test this somehow, by chance? Not sure, but who knows - maybe there is a way :)

So you think renaming this repository and then merging this PR should be enough? Or are there additional steps we need to take?

@sprankhub
Copy link
Contributor

/plan

Copy link

Copy link

Terraform Plan failure

Show Plan

terraform
Acquiring state lock. This may take a few moments...
github_team.teams["infrastructure"]: Refreshing state... [id=6847100]
github_team.teams["distribution"]: Refreshing state... [id=6847101]
github_team.teams["content"]: Refreshing state... [id=6847102]
github_repository.mirrors["mirror-adobe-ims"]: Refreshing state... [id=mirror-adobe-ims]
github_repository.mirrors["mirror-magento-zend-log"]: Refreshing state... [id=mirror-magento-zend-log]
github_team.teams["tech-lead"]: Refreshing state... [id=6847098]
github_team.teams["async-events"]: Refreshing state... [id=7998296]
github_repository.mirrors["mirror-magento-cloud-patches"]: Refreshing state... [id=mirror-magento-cloud-patches]
github_team.teams["continuous-integration"]: Refreshing state... [id=8150814]
github_repository.mirrors["mirror-magento2"]: Refreshing state... [id=mirror-magento2]
github_repository.mirrors["mirror-commerce-operations.en"]: Refreshing state... [id=mirror-commerce-operations.en]
github_repository.mirrors["mirror-magento-zend-loader"]: Refreshing state... [id=mirror-magento-zend-loader]
github_repository.mirrors["mirror-composer"]: Refreshing state... [id=mirror-composer]
github_repository.mirrors["mirror-magento-zend-exception"]: Refreshing state... [id=mirror-magento-zend-exception]
github_repository.mirrors["mirror-magento-zend-db"]: Refreshing state... [id=mirror-magento-zend-db]
github_repository.mirrors["mirror-adobe-stock-integration"]: Refreshing state... [id=mirror-adobe-stock-integration]
github_repository.mirrors["mirror-composer-root-update-plugin"]: Refreshing state... [id=mirror-composer-root-update-plugin]
github_repository.mirrors["mirror-commerce-data-export"]: Refreshing state... [id=mirror-commerce-data-export]
github_repository.mirrors["mirror-quality-patches"]: Refreshing state... [id=mirror-quality-patches]
github_repository.mirrors["mirror-inventory-composer-installer"]: Refreshing state... [id=mirror-inventory-composer-installer]
github_repository.mirrors["mirror-magento-zend-memory"]: Refreshing state... [id=mirror-magento-zend-memory]
github_repository.mirrors["mirror-security-package"]: Refreshing state... [id=mirror-security-package]
github_repository.mirrors["mirror-magento-zend-cache"]: Refreshing state... [id=mirror-magento-zend-cache]
github_repository.mirrors["mirror-module-configurable-sample-data-venia"]: Refreshing state... [id=mirror-module-configurable-sample-data-venia]
github_repository.mirrors["mirror-magento2-functional-testing-framework"]: Refreshing state... [id=mirror-magento2-functional-testing-framework]
github_repository.mirrors["mirror-magento2-sample-data"]: Refreshing state... [id=mirror-magento2-sample-data]
github_repository.mirrors["mirror-devdocs"]: Refreshing state... [id=mirror-devdocs]
github_repository.mirrors["mirror-magento-zend-pdf"]: Refreshing state... [id=mirror-magento-zend-pdf]
github_repository.mirrors["mirror-magento2-page-builder"]: Refreshing state... [id=mirror-magento2-page-builder]
github_repository.mirrors["mirror-magento-composer-installer"]: Refreshing state... [id=mirror-magento-composer-installer]
github_repository.mirrors["mirror-inventory"]: Refreshing state... [id=mirror-inventory]
github_repository.mirrors["mirror-magento-coding-standard"]: Refreshing state... [id=mirror-magento-coding-standard]
github_repository.mirrors["mirror-zf1"]: Refreshing state... [id=mirror-zf1]
github_repository.mirrors["mirror-PHPCompatibilityFork"]: Refreshing state... [id=mirror-PHPCompatibilityFork]
github_repository.mirrors["mirror-commerce-admin.en"]: Refreshing state... [id=mirror-commerce-admin.en]
github_repository.mirrors["mirror-composer-dependency-version-audit-plugin"]: Refreshing state... [id=mirror-composer-dependency-version-audit-plugin]
github_repository.mirrors["mirror-page-builder-types"]: Refreshing state... [id=mirror-page-builder-types]
github_repository.mirrors["mirror-data-migration-tool"]: Refreshing state... [id=mirror-data-migration-tool]
data.github_user.mage-os-ci: Reading...
github_membership.users["avstudnitz"]: Refreshing state... [id=Mage-OS:avstudnitz]
github_membership.users["mage-os-ci"]: Refreshing state... [id=Mage-OS:mage-os-ci]
github_membership.users["fballiano"]: Refreshing state... [id=Mage-OS:fballiano]
github_membership.users["Vinai"]: Refreshing state... [id=Mage-OS:Vinai]
github_membership.users["rhoerr"]: Refreshing state... [id=Mage-OS:rhoerr]
github_membership.users["damienwebdev"]: Refreshing state... [id=Mage-OS:damienwebdev]
github_membership.users["DavidLambauer"]: Refreshing state... [id=Mage-OS:DavidLambauer]
github_membership.users["sprankhub"]: Refreshing state... [id=Mage-OS:sprankhub]
github_membership.users["gowrizrh"]: Refreshing state... [id=Mage-OS:gowrizrh]
github_membership.users["johnhughes1984"]: Refreshing state... [id=Mage-OS:johnhughes1984]
github_membership.users["johnprendergast"]: Refreshing state... [id=Mage-OS:johnprendergast]
github_membership.users["wigman"]: Refreshing state... [id=Mage-OS:wigman]
github_membership.users["cmuench"]: Refreshing state... [id=Mage-OS:cmuench]
github_repository.repositories["mageos-magento-zend-memory"]: Refreshing state... [id=mageos-magento-zend-memory]
github_repository.repositories["mageos-commerce-data-export"]: Refreshing state... [id=mageos-commerce-data-export]
github_repository.repositories["mageos-async-events-azure"]: Refreshing state... [id=mageos-async-events-azure]
github_repository.repositories["dev-env-gitpod"]: Refreshing state... [id=dev-env-gitpod]
github_repository.repositories["mageos-inventory-composer-installer"]: Refreshing state... [id=mageos-inventory-composer-installer]
github_repository.repositories["mageos-magento-coding-standard"]: Refreshing state... [id=mageos-magento-coding-standard]
github_repository.repositories["mageos-common-async-events"]: Refreshing state... [id=mageos-common-async-events]
github_repository.repositories["devdocs"]: Refreshing state... [id=devdocs]
github_repository.repositories["mageos-adobe-stock-integration"]: Refreshing state... [id=mageos-adobe-stock-integration]
data.github_user.mage-os-ci: Read complete after 2s [id=100189073]
github_repository.repositories["mageos-composer"]: Refreshing state... [id=mageos-composer]
github_repository.repositories["meta"]: Refreshing state... [id=meta]
github_repository.repositories["magento-gitpod"]: Refreshing state... [id=magento-gitpod]
github_repository.repositories["mageos-async-events"]: Refreshing state... [id=mageos-async-events]
github_repository.repositories["mage-os-website"]: Refreshing state... [id=mage-os-website]
github_repository.repositories["devdocs-website"]: Refreshing state... [id=devdocs-website]
github_repository.repositories["mageos-async-events-aws"]: Refreshing state... [id=mageos-async-events-aws]
github_repository.repositories["mageos-magento-zend-log"]: Refreshing state... [id=mageos-magento-zend-log]
github_repository.repositories["mageos-magento2-functional-testing-framework"]: Refreshing state... [id=mageos-magento2-functional-testing-framework]
github_repository.repositories["mageos-magento-zend-exception"]: Refreshing state... [id=mageos-magento-zend-exception]
github_repository.repositories["mageos-magento2-page-builder"]: Refreshing state... [id=mageos-magento2-page-builder]
github_repository.repositories["mageos-magento-zend-cache"]: Refreshing state... [id=mageos-magento-zend-cache]
github_repository.repositories["mageos-async-events-gcp"]: Refreshing state... [id=mageos-async-events-gcp]
github_repository.repositories["github-actions"]: Refreshing state... [id=github-actions]
github_repository.repositories["mageos-magento-zend-pdf"]: Refreshing state... [id=mageos-magento-zend-pdf]
github_repository.repositories["terraform"]: Refreshing state... [id=terraform]
github_repository.repositories["mageos-magento2"]: Refreshing state... [id=mageos-magento2]
github_repository.repositories["namespace"]: Refreshing state... [id=namespace]
github_repository.repositories["mageos-magento2-sample-data"]: Refreshing state... [id=mageos-magento2-sample-data]
github_repository.repositories["mageos-composer-dependency-version-audit-plugin"]: Refreshing state... [id=mageos-composer-dependency-version-audit-plugin]
github_repository.repositories["mageos-magento-zend-db"]: Refreshing state... [id=mageos-magento-zend-db]
github_repository.repositories["mageos-async-events-sinks"]: Refreshing state... [id=mageos-async-events-sinks]
github_repository.repositories["mageos-magento-composer-installer"]: Refreshing state... [id=mageos-magento-composer-installer]
github_repository.repositories["mageos-inventory"]: Refreshing state... [id=mageos-inventory]
github_repository.repositories["infrastructure"]: Refreshing state... [id=infrastructure]
github_repository.repositories["generate-mirror-repo-js"]: Refreshing state... [id=generate-mirror-repo-js]
github_repository.repositories["mageos-async-events-admin-ui"]: Refreshing state... [id=mageos-async-events-admin-ui]
github_repository.repositories["mageos-magento-zend-loader"]: Refreshing state... [id=mageos-magento-zend-loader]
github_repository.repositories["mageos-PHPCompatibilityFork"]: Refreshing state... [id=mageos-PHPCompatibilityFork]
github_repository.repositories["mageos-composer-root-update-plugin"]: Refreshing state... [id=mageos-composer-root-update-plugin]
github_repository.repositories["mageos-security-package"]: Refreshing state... [id=mageos-security-package]
github_team_membership.members["sprankhub_infrastructure"]: Refreshing state... [id=6847100:sprankhub]
github_team_membership.members["sprankhub_distribution"]: Refreshing state... [id=6847101:sprankhub]
github_team_membership.members["Vinai_infrastructure"]: Refreshing state... [id=6847100:Vinai]
github_team_membership.members["wigman_content"]: Refreshing state... [id=6847102:wigman]
github_team_membership.members["Vinai_tech-lead"]: Refreshing state... [id=6847098:Vinai]
github_team_membership.members["Vinai_content"]: Refreshing state... [id=6847102:Vinai]
github_team_membership.members["cmuench_infrastructure"]: Refreshing state... [id=6847100:cmuench]
github_team_membership.members["johnhughes1984_content"]: Refreshing state... [id=6847102:johnhughes1984]
github_team_membership.members["mage-os-ci_continuous-integration"]: Refreshing state... [id=8150814:mage-os-ci]
github_team_membership.members["fballiano_infrastructure"]: Refreshing state... [id=6847100:fballiano]
github_team_membership.members["damienwebdev_distribution"]: Refreshing state... [id=6847101:damienwebdev]
github_team_membership.members["gowrizrh_async-events"]: Refreshing state... [id=7998296:gowrizrh]
github_team_membership.members["rhoerr_infrastructure"]: Refreshing state... [id=6847100:rhoerr]
github_team_membership.members["avstudnitz_async-events"]: Refreshing state... [id=7998296:avstudnitz]
github_team_membership.members["DavidLambauer_content"]: Refreshing state... [id=6847102:DavidLambauer]
github_team_membership.members["fballiano_distribution"]: Refreshing state... [id=6847101:fballiano]
github_team_membership.members["DavidLambauer_infrastructure"]: Refreshing state... [id=6847100:DavidLambauer]
github_team_membership.members["damienwebdev_infrastructure"]: Refreshing state... [id=6847100:damienwebdev]
github_team_membership.members["johnprendergast_content"]: Refreshing state... [id=6847102:johnprendergast]
github_team_membership.members["Vinai_distribution"]: Refreshing state... [id=6847101:Vinai]
github_team_membership.members["rhoerr_distribution"]: Refreshing state... [id=6847101:rhoerr]
github_branch_protection.mirrors["mirror-composer"]: Refreshing state... [id=BPR_kwDOHynKTc4By-d9]
github_branch_protection.mirrors["mirror-zf1"]: Refreshing state... [id=BPR_kwDOGMKC6M4By-d2]
github_branch_protection.mirrors["mirror-adobe-ims"]: Refreshing state... [id=BPR_kwDOG8FV-s4By-dL]
github_branch_protection.mirrors["mirror-commerce-data-export"]: Refreshing state... [id=BPR_kwDOIIQUpM4By-eH]
github_branch_protection.mirrors["mirror-PHPCompatibilityFork"]: Refreshing state... [id=BPR_kwDOLS132M4C9j09]
github_branch_protection.mirrors["mirror-magento-zend-exception"]: Refreshing state... [id=BPR_kwDOJ6bTUc4CWSNZ]
github_branch_protection.mirrors["mirror-inventory-composer-installer"]: Refreshing state... [id=BPR_kwDOG8L6gs4By-eB]
github_branch_protection.mirrors["mirror-magento2-functional-testing-framework"]: Refreshing state... [id=BPR_kwDOJpbVr84CQwEY]
github_branch_protection.mirrors["mirror-inventory"]: Refreshing state... [id=BPR_kwDOGMKBz84By-dN]
github_branch_protection.mirrors["mirror-magento-zend-cache"]: Refreshing state... [id=BPR_kwDOJ6bSms4CWSNh]
github_branch_protection.mirrors["mirror-data-migration-tool"]: Refreshing state... [id=BPR_kwDOLS5nKM4C9j4W]
github_branch_protection.mirrors["mirror-magento-zend-pdf"]: Refreshing state... [id=BPR_kwDOJ6bR184CWSNf]
github_branch_protection.mirrors["mirror-composer-root-update-plugin"]: Refreshing state... [id=BPR_kwDOG1y6y84By-df]
github_branch_protection.mirrors["mirror-magento-zend-db"]: Refreshing state... [id=BPR_kwDOJ6bNj84CWSNa]
github_branch_protection.mirrors["mirror-security-package"]: Refreshing state... [id=BPR_kwDOGMKCY84By-d1]
github_branch_protection.mirrors["mirror-commerce-admin.en"]: Refreshing state... [id=BPR_kwDOH_yQpc4B1Gmt]
github_branch_protection.mirrors["mirror-adobe-stock-integration"]: Refreshing state... [id=BPR_kwDOG8FefM4By-dZ]
github_branch_protection.mirrors["mirror-page-builder-types"]: Refreshing state... [id=BPR_kwDOGMKFF84By-dc]
github_branch_protection.mirrors["mirror-commerce-operations.en"]: Refreshing state... [id=BPR_kwDOH_yQXM4B1Gm0]
github_branch_protection.mirrors["mirror-magento-coding-standard"]: Refreshing state... [id=BPR_kwDOJpbWgc4CQwEW]
github_branch_protection.mirrors["mirror-module-configurable-sample-data-venia"]: Refreshing state... [id=BPR_kwDOG3Rr984By-dH]
github_branch_protection.mirrors["mirror-devdocs"]: Refreshing state... [id=BPR_kwDOGwaLE84By-dS]
github_branch_protection.mirrors["mirror-magento-zend-loader"]: Refreshing state... [id=BPR_kwDOJ6bQOs4CWSNV]
github_branch_protection.mirrors["mirror-magento2-page-builder"]: Refreshing state... [id=BPR_kwDOGMKCJ84By-dW]
github_branch_protection.mirrors["mirror-magento-composer-installer"]: Refreshing state... [id=BPR_kwDOGMKAG84By-dP]
github_branch_protection.mirrors["mirror-magento-zend-log"]: Refreshing state... [id=BPR_kwDOJ6bT_84CWSNc]
github_branch_protection.mirrors["mirror-magento2-sample-data"]: Refreshing state... [id=BPR_kwDOG3Ro_84By-dJ]
github_branch_protection.mirrors["mirror-magento-cloud-patches"]: Refreshing state... [id=BPR_kwDOJIrSxM4CGjIG]
github_branch_protection.mirrors["mirror-quality-patches"]: Refreshing state... [id=BPR_kwDOJIrSsM4CGjIE]
github_branch_protection.mirrors["mirror-magento-zend-memory"]: Refreshing state... [id=BPR_kwDOJ6bUk84CWSNg]
github_branch_protection.mirrors["mirror-composer-dependency-version-audit-plugin"]: Refreshing state... [id=BPR_kwDOG1y7C84By-d5]
github_branch_protection.mirrors["mirror-magento2"]: Refreshing state... [id=BPR_kwDOGHBHCc4By-d4]

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

Terraform planned the following actions, but then encountered a problem:

  # github_repository.repositories["infrastructure"] will be updated in-place
  ~ resource "github_repository" "repositories" {
        id                          = "infrastructure"
        name                        = "infrastructure"
      ~ topics                      = [
          + "opentofu",
            # (5 unchanged elements hidden)
        ]
        # (35 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

  # github_repository.repositories["opentofu"] will be created
  + resource "github_repository" "repositories" {
      + allow_auto_merge            = false
      + allow_merge_commit          = true
      + allow_rebase_merge          = true
      + allow_squash_merge          = true
      + archived                    = false
      + auto_init                   = true
      + default_branch              = (known after apply)
      + delete_branch_on_merge      = true
      + description                 = "OpenTofu files for managing the organization repository permissions."
      + etag                        = (known after apply)
      + full_name                   = (known after apply)
      + git_clone_url               = (known after apply)
      + has_issues                  = true
      + has_projects                = true
      + has_wiki                    = false
      + 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                        = "opentofu"
      + 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                      = [
          + "adobecommerce",
          + "ecommerce",
          + "mage-os",
          + "magento",
          + "magento2",
        ]
      + visibility                  = (known after apply)
      + web_commit_signoff_required = false
        # (1 unchanged attribute hidden)

      + security_and_analysis (known after apply)
    }

  # github_repository.repositories["terraform"] will be destroyed
  # (because key ["terraform"] is not in for_each map)
  - resource "github_repository" "repositories" {
      - 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
      - auto_init                   = true -> null
      - default_branch              = "main" -> null
      - delete_branch_on_merge      = true -> null
      - description                 = "Terraform files for managing the organization repository permissions." -> null
      - etag                        = "W/\"d84797ac234f7bf26e12680ac4268a72173a278ee54ad30414ae41f315490136\"" -> null
      - full_name                   = "mage-os/terraform" -> null
      - git_clone_url               = "git://github.com/mage-os/terraform.git" -> null
      - has_discussions             = false -> null
      - has_downloads               = false -> null
      - has_issues                  = true -> null
      - has_projects                = true -> null
      - has_wiki                    = false -> null
      - html_url                    = "https://github.com/mage-os/terraform" -> null
      - http_clone_url              = "https://github.com/mage-os/terraform.git" -> null
      - id                          = "terraform" -> null
      - is_template                 = false -> null
      - merge_commit_message        = "PR_TITLE" -> null
      - merge_commit_title          = "MERGE_MESSAGE" -> null
      - name                        = "terraform" -> null
      - node_id                     = "R_kgDOHNQe7Q" -> null
      - primary_language            = "HCL" -> null
      - private                     = false -> null
      - repo_id                     = 483663597 -> null
      - squash_merge_commit_message = "COMMIT_MESSAGES" -> null
      - squash_merge_commit_title   = "COMMIT_OR_PR_TITLE" -> null
      - ssh_clone_url               = "git@github.com:mage-os/terraform.git" -> null
      - svn_url                     = "https://github.com/mage-os/terraform" -> null
      - topics                      = [
          - "adobecommerce",
          - "ecommerce",
          - "mage-os",
          - "magento",
          - "magento2",
        ] -> null
      - visibility                  = "public" -> null
      - vulnerability_alerts        = false -> null
      - web_commit_signoff_required = false -> null
        # (1 unchanged attribute hidden)

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

Plan: 1 to add, 1 to change, 1 to destroy.
Releasing state lock. This may take a few moments...

Issuer: @sprankhub, Action: https://github.com/mage-os/terraform/actions/runs/12756324713

@sprankhub
Copy link
Contributor

@davidtabat the "plan" above shows an error, even though it looks okay. Any idea? Do you think it will be gone when we rename this repository?

@fballiano
Copy link
Contributor

genuine question: if we rename the repo, shouldn't we rename it to a platform-agnostic one like "infrastructure" or something like that?

@davidtabat
Copy link
Author

@sprankhub Yes I tested it. Described in the taiga ticket comment - how exactly https://tree.taiga.io/project/mage-os-mage-os-technical-initiatives/us/37?kanban-status=9349607

@davidtabat
Copy link
Author

@fballiano Yes, agree with you, that indeed sounds better.

@sprankhub
Copy link
Contributor

I agree, but https://github.com/mage-os/infrastructure is taken already :D Other ideas?

  • infrastructure-setup
  • github-setup
  • permissions
  • github-permissions
  • ...

@davidtabat
Copy link
Author

I tested renaming on a dummy repo, and even after renaming it on GitHub, there were still errors due to the state saved in the backend. For now, I’ll take some time to figure out how to do it properly. 😄

Regarding the name, I think 'infrastructure-setup' is good. Maybe we should create a poll in Discord? Or is this too small of a matter to give so much attention to?"

@DavidLambauer
Copy link
Contributor

Are we sure that this switch won't result in a lock change or even worse in a re-creation of existing repos?

@DavidLambauer
Copy link
Contributor

So, for example, when we destroy the tf repo, can this have an impact on any other repos?

@davidtabat
Copy link
Author

@DavidLambauer It shouldn't, but I will test that here to be sure ofc: https://github.com/orgs/test-opentofu-mageos/repositories.

@fballiano
Copy link
Contributor

Regarding the name, I think 'infrastructure-setup' is good.

I'm nobody to decide anything but I'm fine with infrastructure-setup

Are we sure that this switch won't result in a lock change or even worse in a re-creation of existing repos?

I sincerely hope TF doesn't work that way, is there a way to know?

@DavidLambauer
Copy link
Contributor

In the early days, I ran into some lock issues, and that's why I am asking. If it's properly tested, we should be fine I guess.

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.

4 participants