I have more than 40 Terraform modules to register in a private Terraform Enterprise module registry.

It would be difficult to create 40 GitHub repositories for each of the 40 modules I am publishing.

Is it possible to have one GitHub repository and have one sub-directory per module (means 40 directories for 40 modules) ? This way, I need to manage only one repository and have all modules in its subdirectories.

1

There are 1 best solutions below

4
Mohammed Almusaddar On BEST ANSWER

You can use root module for the 40 modules and call submodule by //sub_module_folder at the end of source parameter.

but a better solution would be use Terraform to Automate the addition of the 40 modules using tfe_registry_module

basic usage:

resource "tfe_organization" "test-organization" {
  name  = "my-org-name"
  email = "[email protected]"
}

resource "tfe_oauth_client" "test-oauth-client" {
  organization     = tfe_organization.test-organization.name
  api_url          = "https://api.github.com"
  http_url         = "https://github.com"
  oauth_token      = "my-vcs-provider-token"
  service_provider = "github"
}

resource "tfe_registry_module" "test-registry-module" {
  vcs_repo {
    display_identifier = "gh-org-name/terraform-provider-name"
    identifier         = "gh-org-name/terraform-provider-name"
    oauth_token_id     = tfe_oauth_client.test-oauth-client.oauth_token_id
  }
}
resource "tfe_registry_module" "test-registry-module-2" {
  vcs_repo {
    display_identifier = "gh-org-name/terraform-provider-name-2"
    identifier         = "gh-org-name/terraform-provider-name-2"
    oauth_token_id     = tfe_oauth_client.test-oauth-client.oauth_token_id
  }
}