locals { repositories = yamldecode(file("repositories.yaml")) } resource "github_repository" "repos" { for_each = local.repositories name = try(each.value.name, each.key) visibility = each.value.visibility archived = each.value.archived description = try(each.value.description, null) has_downloads = false has_issues = try(each.value.has_issues, true) has_projects = false has_wiki = false allow_merge_commit = false allow_squash_merge = true allow_rebase_merge = true vulnerability_alerts = try(each.value.vulnerability_alerts, false) delete_branch_on_merge = try(each.value.vulnerability_alerts, false) } resource "github_branch_default" "main" { # no need to set the default branch if the repository is already # archived. # use the name for the repository if set for_each = { for k, v in local.repositories : try(v.name, k) => v if v.archived == false } repository = each.key branch = try(each.value.default_branch, "main") }