Skip to content

Instantly share code, notes, and snippets.

@devops-adeel
Last active March 25, 2022 19:23
Show Gist options
  • Save devops-adeel/e4d9c5cdfc8a6372254c64ca03e54eb2 to your computer and use it in GitHub Desktop.
Save devops-adeel/e4d9c5cdfc8a6372254c64ca03e54eb2 to your computer and use it in GitHub Desktop.
MVP TF module for TF-Module Registry for every TFE/C org.
variable "tfe_org" {}
data "vault_generic_secret" "default" {
path = "secret/github_auth"
}
data "tfe_organization" "default" {
name = var.tfe_org
}
data "github_repositories" "default" {
query = "org:terraform-org-modules"
}
data "http" "default" {
url = "https://github.com"
}
data "http" "api" {
url = "https://api.github.com"
}
resource "tfe_oauth_client" "default" {
name = "terraform-org-modules"
api_url = data.http.api.url
http_url = data.http.default.url
service_provider = "github"
organization = data.tfe_organization.default.name
oauth_token = data.vault_generic_secret.default.data["token"]
}
resource "tfe_registry_module" "default" {
for_each = toset(data.github_repositories.default.full_names)
vcs_repo {
display_identifier = each.key
identifier = each.key
oauth_token_id = tfe_oauth_client.default.oauth_token_id
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment