Skip to content

Instantly share code, notes, and snippets.

@benmatselby
Last active April 11, 2021 10:41
Show Gist options
  • Save benmatselby/e56b9d95d14358b6fc8361988e13c252 to your computer and use it in GitHub Desktop.
Save benmatselby/e56b9d95d14358b6fc8361988e13c252 to your computer and use it in GitHub Desktop.
Terraform GitHub Repo Admin
provider "github" {
token = var.github_token
owner = var.github_org
}
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"]
}
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