Skip to content

Commit

Permalink
Create sanitech_user_management.tf
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH committed Apr 19, 2024
1 parent 4db31b6 commit 01a2d8d
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions func/sanitech_user_management.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Configure the Azure provider
provider "azurerm" {
features {}
}

# Create a resource group
resource "azurerm_resource_group" "sanitech_rg" {
name = "sanitech-rg"
location = "East US"
}

# Create a Azure Active Directory group for Sanitech users
resource "azurerm_group" "sanitech_users" {
name = "sanitech-users"
location = azurerm_resource_group.sanitech_rg.location
resource_group_name = azurerm_resource_group.sanitech_rg.name
}

# Create a Azure Active Directory group for Sanitech administrators
resource "azurerm_group" "sanitech_admins" {
name = "sanitech-admins"
location = azurerm_resource_group.sanitech_rg.location
resource_group_name = azurerm_resource_group.sanitech_rg.name
}

# Add users to the Sanitech users group
resource "azurerm_group_member" "sanitech_user_member" {
for_each = toset(var.sanitech_users)
group_object_id = azurerm_group.sanitech_users.id
member_object_id = data.azurerm_user.sanitech_user[each.value].id
}

# Add users to the Sanitech administrators group
resource "azurerm_group_member" "sanitech_admin_member" {
for_each = toset(var.sanitech_admins)
group_object_id = azurerm_group.sanitech_admins.id
member_object_id = data.azurerm_user.sanitech_user[each.value].id
}

# Get users from Azure Active Directory
data "azurerm_user" "sanitech_user" {
for_each = toset(var.sanitech_users)
user_principal_name = each.value
}

# Define a variable for Sanitech users
variable "sanitech_users" {
type = list(string)
description = "List of Sanitech user email addresses"
default = []
}

# Define a variable for Sanitech administrators
variable "sanitech_admins" {
type = list(string)
description = "List of Sanitech administrator email addresses"
default = []
}

0 comments on commit 01a2d8d

Please sign in to comment.