From 7c01d11ee26c8c0ac693e1d2d0c232746f362b8f Mon Sep 17 00:00:00 2001 From: Robin Bowes Date: Thu, 13 Aug 2026 12:25:36 +0100 Subject: [PATCH] fix: re-import the transferred repos at their new names --- imports.tf | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ main.tf | 15 --------------- 2 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 imports.tf diff --git a/imports.tf b/imports.tf new file mode 100644 index 0000000..d5bf114 --- /dev/null +++ b/imports.tf @@ -0,0 +1,55 @@ +# Temporary: re-adopts the two repos transferred from yo61 to ycst-org-uk on +# 2026-08-13. Delete once applied. +# +# `moved` blocks were the intended mechanism and half worked: they rebound each +# resource to the ycst_org_uk provider and the renamed for_each key, exactly as +# the migration design's experiment predicted. What they cannot do is rewrite a +# resource ID, and for github_repository the ID *is* the repo name. State held +# `ycst-admin-docs`, so refresh asked GitHub for ycst-org-uk/ycst-admin-docs and +# got 404 — the rename redirect is keyed on the original owner/name pair +# (yo61/ycst-admin-docs), not on the old name under the new owner. Terraform +# read the 404 as "resource is gone" and planned to create it. +# +# The stale entries were dropped with `terraform state rm` (GitHub untouched); +# these blocks adopt the same objects at their new addresses under their new +# names. `removed` blocks cannot do the dropping — they reject instance keys. + +import { + to = module.org_ycst_org_uk.module.repo["board-docs"].github_repository.this + id = "board-docs" +} + +import { + to = module.org_ycst_org_uk.module.repo["board-docs"].github_repository_collaborators.this + id = "board-docs" +} + +import { + to = module.org_ycst_org_uk.module.repo["board-docs"].github_repository_vulnerability_alerts.this["this"] + id = "board-docs" +} + +import { + to = module.org_ycst_org_uk.module.repo["board-docs"].github_repository_dependabot_security_updates.this["this"] + id = "board-docs" +} + +import { + to = module.org_ycst_org_uk.module.repo["website-testing"].github_repository.this + id = "website-testing" +} + +import { + to = module.org_ycst_org_uk.module.repo["website-testing"].github_repository_collaborators.this + id = "website-testing" +} + +import { + to = module.org_ycst_org_uk.module.repo["website-testing"].github_repository_vulnerability_alerts.this["this"] + id = "website-testing" +} + +import { + to = module.org_ycst_org_uk.module.repo["website-testing"].github_repository_dependabot_security_updates.this["this"] + id = "website-testing" +} diff --git a/main.tf b/main.tf index 45baedd..baa2e7e 100644 --- a/main.tf +++ b/main.tf @@ -33,18 +33,3 @@ module "org_ycst_org_uk" { github = github.ycst_org_uk } } - -# The repos were transferred and renamed on GitHub out of band; github_repository -# takes its owner from the provider, so terraform cannot do the move itself. -# One block per repo carries all four of that repo's instances across both the -# provider alias and the renamed for_each key, preserving the resource ID. -# Delete these once applied — a spent moved block is a no-op. -moved { - from = module.org_yo61.module.repo["ycst-admin-docs"] - to = module.org_ycst_org_uk.module.repo["board-docs"] -} - -moved { - from = module.org_yo61.module.repo["ycst-website-testing"] - to = module.org_ycst_org_uk.module.repo["website-testing"] -}