https://github.com/thesoftwarehouse/terraform-azurerm-role-assignment
Terraform Module to assign Azure IAM roles
https://github.com/thesoftwarehouse/terraform-azurerm-role-assignment
azure azurerm role-assignment terraform tsh
Last synced: 3 months ago
JSON representation
Terraform Module to assign Azure IAM roles
- Host: GitHub
- URL: https://github.com/thesoftwarehouse/terraform-azurerm-role-assignment
- Owner: TheSoftwareHouse
- License: gpl-3.0
- Created: 2024-07-19T11:08:30.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-11-14T14:52:46.000Z (7 months ago)
- Last Synced: 2025-01-11T13:27:41.659Z (5 months ago)
- Topics: azure, azurerm, role-assignment, terraform, tsh
- Language: HCL
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# terraform-role-assignment
## Assign roles to users, groups and service principals
This Terraform module assigns `BUILT IN` roles to users, groups and service principals.
## Usage
NOTE: Assigning the same role to the same user, group or service principal multiple times will merge it, so when you do:
```hcl
module "role_assignments" {
source = "retoxx-dev/role-assignment/azurerm"role_assignments = [
{
user_principal_names = ["[email protected]"]
role_names = ["Reader", "Web Plan Contributor"]
scope = azurerm_resource_group.this.id
},
{
user_principal_names = ["[email protected]", "[email protected]"]
role_names = ["Reader", "Owner"]
scope = azurerm_resource_group.this.id
}
]
}
```
The role `Reader` will be assigned to `[email protected]` only once.### Assign roles to users
```hcl
module "role_assignments" {
source = "retoxx-dev/role-assignment/azurerm"role_assignments = [
{
user_principal_names = ["[email protected]", "[email protected]"]
role_names = ["Reader", "Web Plan Contributor"]
scope = azurerm_resource_group.this.id
}
]
}
```### Assign roles to groups
```hcl
module "role_assignments" {
source = "retoxx-dev/role-assignment/azurerm"role_assignments = [
{
group_names = ["group1", "group2", "group3"]
role_names = ["Reader", "Web Plan Contributor"]
scope = azurerm_resource_group.this.id
}
]
}
```### Assign roles to service principals
```hcl
module "role_assignments" {
source = "retoxx-dev/role-assignment/azurerm"role_assignments = [
{
sp_names = ["spname1", "spname2", "spname3"]
role_names = ["Reader", "Web Plan Contributor"]
scope = azurerm_resource_group.this.id
}
]
}
```### Assign roles to service principals but with principal ids
```hcl
module "role_assignments" {
source = "retoxx-dev/role-assignment/azurerm"role_assignments = [
{
principal_ids = ["00000000-0000-0000-0000-000000000000"]
role_names = ["Reader", "Web Plan Contributor"]
scope = azurerm_resource_group.this.id
}
]
}
```## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.3.1 |
| [azuread](#requirement\_azuread) | >=2.37 |
| [azurerm](#requirement\_azurerm) | >=3.33 |## Providers
| Name | Version |
|------|---------|
| [azuread](#provider\_azuread) | >=2.37 |
| [azurerm](#provider\_azurerm) | >=3.33 |## Modules
No modules.
## Resources
| Name | Type |
|------|------|
| [azurerm_role_assignment.groups](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) | resource |
| [azurerm_role_assignment.principal_ids](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) | resource |
| [azurerm_role_assignment.service_principals](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) | resource |
| [azurerm_role_assignment.users](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) | resource |
| [azuread_group.group_objects](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/group) | data source |
| [azuread_service_principal.sp_objects](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/service_principal) | data source |
| [azuread_user.user_objects](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/user) | data source |## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [role\_assignments](#input\_role\_assignments) | The role assignments to create |list(object({| n/a | yes |
user_principal_names = optional(list(string), [])
group_names = optional(list(string), [])
sp_names = optional(list(string), [])
principal_ids = optional(list(string), [])
role_names = list(string)
scope = string
}))## Outputs
No outputs.