Skip to content

Commit 1060376

Browse files
authored
Merge pull request #2 from codycodes/updates-per-feedback
Updates Per Roger's Feedback
2 parents fe06f1c + b69aa5e commit 1060376

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

README.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,7 @@
2222

2323
### Basic Usage
2424

25-
```hcl
26-
module "ms365_hass_calendar" {
27-
source = "codycodes/ms365-hass/azuread"
28-
version = "~>1.0"
29-
30-
selected_service = "calendar"
31-
}
32-
```
33-
34-
Please see the [examples](./examples) folder for more configurations, or take a look at the [variables](./variables.tf) page to see the inputs supported by this module.
25+
Please see the [examples](./examples) folder for a configuration example (that calls this module), take a look at the a fancy rendering of the inputs [on the module's Terraform Registry page](https://registry.terraform.io/modules/codycodes/ms365-hass/azuread/latest?tab=inputs) or peep the [variables](./variables.tf) page directly to see the inputs supported by this module.
3526

3627
### Setup
3728

main.tf

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ locals {
5757

5858
data "azuread_client_config" "current" {}
5959

60+
locals {
61+
assigned_permissions = var.preassign_permissions ? concat(local.permissions.general, local.permissions[var.selected_service]) : []
62+
}
63+
6064
resource "azuread_application" "m365_integration" {
6165
display_name = "Home Assistant MS365 ${var.selected_service} Integration"
6266
description = "Created via Terraform"
@@ -65,13 +69,18 @@ resource "azuread_application" "m365_integration" {
6569
api {
6670
requested_access_token_version = 2 # required for some sign_in_audience & recommended due to backwards compat w/v1
6771
}
68-
required_resource_access {
69-
resource_app_id = "00000003-0000-0000-c000-000000000000" # microsoft graph
70-
dynamic "resource_access" {
71-
for_each = var.custom_permissions == null ? concat(local.permissions.general, local.permissions[var.selected_service]) : tolist(var.custom_permissions)
72-
content {
73-
id = resource_access.value
74-
type = "Scope"
72+
dynamic "required_resource_access" {
73+
for_each = length(local.assigned_permissions) > 0 ? [1] : []
74+
75+
content {
76+
resource_app_id = "00000003-0000-0000-c000-000000000000" # microsoft graph
77+
dynamic "resource_access" {
78+
for_each = local.assigned_permissions
79+
80+
content {
81+
id = resource_access.value
82+
type = "Scope"
83+
}
7584
}
7685
}
7786
}

variables.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ variable "rotation_window_days" {
3838
default = 365
3939
}
4040

41-
variable "custom_permissions" {
42-
type = set(string)
43-
description = "Custom permissions to use instead of local.permissions"
44-
default = null
41+
variable "preassign_permissions" {
42+
type = bool
43+
description = "Determines whether permissions for the app should be pre-assigned (greatest privilege) or assigned at auth-time (least privilege)"
44+
default = false
4545
}
4646

4747
variable "owners" {

0 commit comments

Comments
 (0)