Last active
February 2, 2019 22:55
-
-
Save dgmorales/a566054ae403a23b1cbbd4b0248f7efb to your computer and use it in GitHub Desktop.
A GitHub org member map terraform module example
This file contains hidden or 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
# modules/org-member/variable.tf | |
variable "email" { | |
description = "email - (Required) The email address of the user" | |
} | |
variable "role" { | |
description = "role - (Optional) The user role in the org" | |
default = "member" | |
} | |
# modules/org-member/main.tf | |
module "user_map" { | |
source = "../../org/map" | |
} | |
locals { | |
github_nickname = "${lookup(module.user_map.map, var.email)}" | |
} | |
data "github_team" "all-org-members" { | |
slug = "all-org-members" | |
} | |
resource "github_membership" "org-member" { | |
username = "${local.github_nickname}" | |
role = "${var.role}" | |
} | |
resource "github_team_membership" "all-org-members" { | |
team_id = "${data.github_team.all-org-members.id}" | |
username = "${local.github_nickname}" | |
role = "member" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment