Last active
April 11, 2021 10:41
-
-
Save benmatselby/e56b9d95d14358b6fc8361988e13c252 to your computer and use it in GitHub Desktop.
Terraform GitHub Repo Admin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "github" { | |
token = var.github_token | |
owner = var.github_org | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "github_repository" "repos" { | |
for_each = var.github_repos | |
name = each.value["name"] | |
description = each.value["description"] | |
archived = each.value["archived"] | |
// Settings | |
visibility = "private" | |
has_downloads = true | |
has_issues = true | |
has_wiki = true | |
vulnerability_alerts = true | |
// Merge settings | |
allow_merge_commit = true | |
allow_squash_merge = false | |
allow_rebase_merge = false | |
delete_branch_on_merge = true | |
// Topics | |
topics = each.value["topics"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "github_token" { | |
type = string | |
description = "The access token to GitHub" | |
} | |
variable "github_org" { | |
type = string | |
description = "The GitHub organisation" | |
default = "benmatselby" | |
} | |
variable "github_repos" { | |
type = map | |
description = "All our repos we want to manage using Terraform" | |
default = { | |
tfgithubadmin = { | |
"name" : "tf-github-admin", | |
"description" : "The Terraform configuration to manage GitHub repos", | |
"topics" : ["terraform", "automation"], | |
"archived": false | |
}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment