diff --git a/alz/github/main.tf b/alz/github/main.tf index 7d28f7d..f5a9935 100644 --- a/alz/github/main.tf +++ b/alz/github/main.tf @@ -78,6 +78,7 @@ module "github" { organization_name = var.github_organization_name environments = local.environments repository_name = local.resource_names.version_control_system_repository + repository_visibility = var.repository_visibility use_template_repository = var.use_separate_repository_for_templates repository_name_templates = local.resource_names.version_control_system_repository_templates repository_files = local.repository_files diff --git a/alz/github/variables.tf b/alz/github/variables.tf index af8545c..e3437b6 100644 --- a/alz/github/variables.tf +++ b/alz/github/variables.tf @@ -87,6 +87,16 @@ variable "use_separate_repository_for_templates" { default = true } +variable "repository_visibility" { + description = "Can be public or private. If your organization is associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+, visibility can also be internal. The visibility parameter overrides the private parameter." + type = string + default = "private" + validation { + condition = contains(["private", "public", "internal"], var.repository_visibility) + error_message = "The repository visibility must be either of (private|public|internal)" + } +} + variable "bootstrap_subscription_id" { description = "Azure Subscription ID for the bootstrap resources (e.g. storage account, identities, etc). Leave empty to use the az login subscription" type = string diff --git a/modules/github/repository_module.tf b/modules/github/repository_module.tf index 06aeda1..ea94ef4 100644 --- a/modules/github/repository_module.tf +++ b/modules/github/repository_module.tf @@ -2,7 +2,7 @@ resource "github_repository" "alz" { name = var.repository_name description = var.repository_name auto_init = true - visibility = data.github_organization.alz.plan == local.free_plan ? "public" : "private" + visibility = var.repository_visibility allow_update_branch = true allow_merge_commit = false allow_rebase_merge = false diff --git a/modules/github/repository_templates.tf b/modules/github/repository_templates.tf index 92a3924..65dad83 100644 --- a/modules/github/repository_templates.tf +++ b/modules/github/repository_templates.tf @@ -3,7 +3,7 @@ resource "github_repository" "alz_templates" { name = var.repository_name_templates description = var.repository_name_templates auto_init = true - visibility = data.github_organization.alz.plan == local.free_plan ? "public" : "private" + visibility = var.repository_visibility allow_update_branch = true allow_merge_commit = false allow_rebase_merge = false diff --git a/modules/github/variables.tf b/modules/github/variables.tf index c2ec9f8..6d872b5 100644 --- a/modules/github/variables.tf +++ b/modules/github/variables.tf @@ -91,3 +91,7 @@ variable "use_self_hosted_runners" { variable "create_branch_policies" { type = bool } + +variable "repository_visibility" { + type = string +}