Skip to content

Commit 595dcf5

Browse files
committed
Switched from using a map to an array - this is simpler and in keeping with the way the resource should be defined.
1 parent 5206559 commit 595dcf5

File tree

7 files changed

+22
-44
lines changed

7 files changed

+22
-44
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ No modules.
287287
| <a name="input_permission_sets"></a> [permission\_sets](#input\_permission\_sets) | Permission Sets that you wish to create in IAM Identity Center. This variable is a map of maps containing Permission Set names as keys. See permission\_sets description in README for information about map values. | `any` | `{}` | no |
288288
| <a name="input_sso_applications"></a> [sso\_applications](#input\_sso\_applications) | List of applications to be created in IAM Identity Center | <pre>map(object({<br> name = string<br> application_provider_arn = string<br> description = optional(string)<br> portal_options = optional(object({<br> sign_in_options = optional(object({<br> application_url = optional(string)<br> origin = string<br> }))<br> visibility = optional(string)<br> }))<br> status = string # acceptable values are "ENABLED" or "DISABLED"<br> client_token = optional(string)<br> tags = optional(map(string))<br> assignment_required = bool # Resource: aws_ssoadmin_application_assignment_configuration<br> assignments_access_scope = optional(<br> list(object({<br> authorized_targets = optional(list(string)) # List of application names<br> scope = string<br> }))<br> ) # Resource: aws_ssoadmin_application_access_scope<br> group_assignments = optional(list(string)) # Resource aws_ssoadmin_application_assignment, keeping it separated for groups<br> user_assignments = optional(list(string)) # Resource aws_ssoadmin_application_assignment, keeping it separated for users<br> }))</pre> | `{}` | no |
289289
| <a name="input_sso_groups"></a> [sso\_groups](#input\_sso\_groups) | Names of the groups you wish to create in IAM Identity Center. | <pre>map(object({<br> group_name = string<br> group_description = optional(string, null)<br> }))</pre> | `{}` | no |
290-
| <a name="input_sso_instance_access_control_attributes"></a> [sso\_instance\_access\_control\_attributes](#input\_sso\_instance\_access\_control\_attributes) | List of attributes for access control. This is used to create the enable and use attributes for access control. | <pre>map(object({<br> attribute_name = string<br> source = set(string)<br> }))</pre> | `{}` | no |
290+
| <a name="input_sso_instance_access_control_attributes"></a> [sso\_instance\_access\_control\_attributes](#input\_sso\_instance\_access\_control\_attributes) | List of attributes for access control. This is used to create the enable and use attributes for access control. | <pre>list(object({<br> attribute_name = string<br> source = set(string)<br> }))</pre> | `[]` | no |
291291
| <a name="input_sso_users"></a> [sso\_users](#input\_sso\_users) | Names of the users you wish to create in IAM Identity Center. | <pre>map(object({<br> display_name = optional(string)<br> user_name = string<br> group_membership = list(string)<br> # Name<br> given_name = string<br> middle_name = optional(string, null)<br> family_name = string<br> name_formatted = optional(string)<br> honorific_prefix = optional(string, null)<br> honorific_suffix = optional(string, null)<br> # Email<br> email = string<br> email_type = optional(string, null)<br> is_primary_email = optional(bool, true)<br> # Phone Number<br> phone_number = optional(string, null)<br> phone_number_type = optional(string, null)<br> is_primary_phone_number = optional(bool, true)<br> # Address<br> country = optional(string, " ")<br> locality = optional(string, " ")<br> address_formatted = optional(string)<br> postal_code = optional(string, " ")<br> is_primary_address = optional(bool, true)<br> region = optional(string, " ")<br> street_address = optional(string, " ")<br> address_type = optional(string, null)<br> # Additional<br> user_type = optional(string, null)<br> title = optional(string, null)<br> locale = optional(string, null)<br> nickname = optional(string, null)<br> preferred_language = optional(string, null)<br> profile_url = optional(string, null)<br> timezone = optional(string, null)<br> }))</pre> | `{}` | no |
292292

293293
## Outputs
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
This directory contains examples of using the module to **create** instance access control attributes.
22

3-
**IMPORTANT:** Ensure that the name of your object matches the name of your principal (e.g. user name or group name). See the following example with object/principal names 'FirstName' and 'LastName':
4-
53
```hcl
6-
sso_instance_access_control_attributes = {
7-
FirstName = {
4+
sso_instance_access_control_attributes = [
5+
{
86
attribute_name = "FirstName"
97
source = ["$${path:name.givenName}"]
10-
}
11-
LastName = {
8+
},
9+
{
1210
attribute_name = "LastName"
1311
source = ["$${path:name.familyName}"]
1412
}
15-
}
16-
13+
]
1714
```

examples/instance-access-control-attributes/README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
<!-- BEGIN_TF_DOCS -->
22
This directory contains examples of using the module to **create** instance access control attributes.
33

4-
**IMPORTANT:** Ensure that the name of your object matches the name of your principal (e.g. user name or group name). See the following example with object/principal names 'FirstName' and 'LastName':
5-
64
```hcl
7-
sso_instance_access_control_attributes = {
8-
FirstName = {
5+
sso_instance_access_control_attributes = [
6+
{
97
attribute_name = "FirstName"
108
source = ["$${path:name.givenName}"]
11-
}
12-
LastName = {
9+
},
10+
{
1311
attribute_name = "LastName"
1412
source = ["$${path:name.familyName}"]
1513
}
16-
}
17-
14+
]
1815
```
1916

2017
## Requirements

examples/instance-access-control-attributes/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ module "aws-iam-identity-center" {
22
source = "../.." // local example
33

44
//Create desired access control attributes
5-
sso_instance_access_control_attributes = {
6-
FirstName = {
5+
sso_instance_access_control_attributes = [
6+
{
77
attribute_name = "FirstName"
88
source = ["$${path:name.givenName}"]
9-
}
10-
LastName = {
9+
},
10+
{
1111
attribute_name = "LastName"
1212
source = ["$${path:name.familyName}"]
1313
}
14-
}
14+
]
1515
}

locals.tf

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,3 @@ locals {
218218
]
219219
])
220220
}
221-
222-
# - IAM Access Control Attributes
223-
locals {
224-
# If user provides attributes, use those. If null/empty, provide minimum required
225-
attributes_to_use = (
226-
var.sso_instance_access_control_attributes != {}) ? var.sso_instance_access_control_attributes : {
227-
# This default will only be used during plan phase and resource won't actually be created
228-
Dummy = {
229-
attribute_name = "Dummy"
230-
source = ["dummy"]
231-
}
232-
}
233-
}

main.tf

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,12 @@ resource "aws_ssoadmin_instance_access_control_attributes" "sso_access_control_
323323
count = length(var.sso_instance_access_control_attributes) <= 0 ? 0 : 1
324324
instance_arn = local.ssoadmin_instance_arn
325325
dynamic "attribute" {
326-
for_each = local.attributes_to_use
326+
for_each = var.sso_instance_access_control_attributes
327327
content {
328328
key = attribute.key
329329
value {
330330
source = attribute.value.source
331331
}
332332
}
333333
}
334-
lifecycle { #TODO: need to check that this is a best practice and/or see if we should allow the user to define and/or override.
335-
create_before_destroy = true
336-
}
337334
}

variables.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,26 +149,26 @@ variable "sso_applications" {
149149
#Access Control Attributes
150150
variable "sso_instance_access_control_attributes" {
151151
description = "List of attributes for access control. This is used to create the enable and use attributes for access control."
152-
type = map(object({
152+
type = list(object({
153153
attribute_name = string
154154
source = set(string)
155155
}))
156-
default = {}
156+
default = []
157157
validation {
158158
condition = alltrue([
159-
for attr in values(var.sso_instance_access_control_attributes) :
159+
for attr in var.sso_instance_access_control_attributes :
160160
attr.attribute_name != null &&
161161
attr.attribute_name != ""
162162
])
163163
error_message = "The attribute_name field is mandatory for all attributes."
164164
}
165165
validation {
166166
condition = alltrue([
167-
for attr in values(var.sso_instance_access_control_attributes) :
167+
for attr in var.sso_instance_access_control_attributes :
168168
attr.source != null &&
169169
length(attr.source) > 0 && # checks if the set is not empty
170170
alltrue([for s in attr.source : s != ""]) # checks no empty strings in set
171171
])
172172
error_message = "The attribute source is mandatory and must contain non-empty strings."
173173
}
174-
}
174+
}

0 commit comments

Comments
 (0)