Skip to content

Commit 2d02931

Browse files
authored
Merge pull request #49 from reste85/feat/iam-idc-application-support
feat: add support for IAM IdC Applications (with testing)
2 parents 7536bb4 + f758cca commit 2d02931

File tree

18 files changed

+920
-2
lines changed

18 files changed

+920
-2
lines changed

.header.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Dynamic Reference of Existing Groups
1212
- AWS Managed Policy Support
1313
- Customer Managed Policy Support
14+
- Dynamic Application Creation (with Portal Options, Users and Groups assignments and Assignments Access Scopes configuration)
1415

1516
## Important
1617

@@ -37,6 +38,32 @@
3738
},
3839
}
3940
41+
// Create desired Applications in IAM Identity Center
42+
sso_applications = {
43+
FirstApplication : {
44+
application_provider_arn = "arn:aws:sso::aws:applicationProvider/custom"
45+
description = "I am the First Application"
46+
name = "FirstApplication"
47+
portal_options = {
48+
sign_in_options = {
49+
application_url = "http://example.com"
50+
origin = "APPLICATION"
51+
}
52+
visibility = "ENABLED"
53+
}
54+
status = "ENABLED"
55+
assignment_required = true
56+
assignments_access_scope = [
57+
{
58+
authorized_targets = ["FirstApplication"]
59+
scope = "sso:account:access"
60+
}
61+
]
62+
group_assignments = ["Dev"]
63+
user_assignments = ["nuzumaki"]
64+
}
65+
}
66+
4067
```
4168

4269
The object/principal names are referenced throughout the module. Failure to follow this guidance may lead to unintentional errors such as the following:
@@ -167,6 +194,36 @@ module "aws-iam-identity-center" {
167194
}
168195
```
169196

197+
## Basic Usage - Create Applications and assign to Users and Groups
198+
199+
```
200+
// Create desired Applications in IAM Identity Center
201+
sso_applications = {
202+
FirstApplication : {
203+
application_provider_arn = "arn:aws:sso::aws:applicationProvider/custom"
204+
description = "I am the First Application"
205+
name = "FirstApplication"
206+
portal_options = {
207+
sign_in_options = {
208+
application_url = "http://example.com"
209+
origin = "APPLICATION"
210+
}
211+
visibility = "ENABLED"
212+
}
213+
status = "ENABLED"
214+
assignment_required = true
215+
assignments_access_scope = [
216+
{
217+
authorized_targets = ["FirstApplication"]
218+
scope = "sso:account:access"
219+
}
220+
]
221+
group_assignments = ["Dev"]
222+
user_assignments = ["nuzumaki"]
223+
}
224+
}
225+
```
226+
170227
## Contributing
171228

172229
See the `CONTRIBUTING.md` file for information on how to contribute.

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- Dynamic Reference of Existing Groups
1313
- AWS Managed Policy Support
1414
- Customer Managed Policy Support
15+
- Dynamic Application Creation (with Portal Options, Users and Groups assignments and Assignments Access Scopes configuration)
1516

1617
## Important
1718

@@ -38,6 +39,32 @@
3839
},
3940
}
4041
42+
// Create desired Applications in IAM Identity Center
43+
sso_applications = {
44+
FirstApplication : {
45+
application_provider_arn = "arn:aws:sso::aws:applicationProvider/custom"
46+
description = "I am the First Application"
47+
name = "FirstApplication"
48+
portal_options = {
49+
sign_in_options = {
50+
application_url = "http://example.com"
51+
origin = "APPLICATION"
52+
}
53+
visibility = "ENABLED"
54+
}
55+
status = "ENABLED"
56+
assignment_required = true
57+
assignments_access_scope = [
58+
{
59+
authorized_targets = ["FirstApplication"]
60+
scope = "sso:account:access"
61+
}
62+
]
63+
group_assignments = ["Dev"]
64+
user_assignments = ["nuzumaki"]
65+
}
66+
}
67+
4168
```
4269

4370
The object/principal names are referenced throughout the module. Failure to follow this guidance may lead to unintentional errors such as the following:
@@ -168,6 +195,36 @@ module "aws-iam-identity-center" {
168195
}
169196
```
170197

198+
## Basic Usage - Create Applications and assign to Users and Groups
199+
200+
```
201+
// Create desired Applications in IAM Identity Center
202+
sso_applications = {
203+
FirstApplication : {
204+
application_provider_arn = "arn:aws:sso::aws:applicationProvider/custom"
205+
description = "I am the First Application"
206+
name = "FirstApplication"
207+
portal_options = {
208+
sign_in_options = {
209+
application_url = "http://example.com"
210+
origin = "APPLICATION"
211+
}
212+
visibility = "ENABLED"
213+
}
214+
status = "ENABLED"
215+
assignment_required = true
216+
assignments_access_scope = [
217+
{
218+
authorized_targets = ["FirstApplication"]
219+
scope = "sso:account:access"
220+
}
221+
]
222+
group_assignments = ["Dev"]
223+
user_assignments = ["nuzumaki"]
224+
}
225+
}
226+
```
227+
171228
## Contributing
172229

173230
See the `CONTRIBUTING.md` file for information on how to contribute.
@@ -199,6 +256,11 @@ No modules.
199256
| [aws_identitystore_group_membership.sso_group_membership_existing_google_sso_users](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/identitystore_group_membership) | resource |
200257
| [aws_identitystore_user.sso_users](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/identitystore_user) | resource |
201258
| [aws_ssoadmin_account_assignment.account_assignment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_account_assignment) | resource |
259+
| [aws_ssoadmin_application.sso_apps](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_application) | resource |
260+
| [aws_ssoadmin_application_access_scope.sso_apps_assignments_access_scope](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_application_access_scope) | resource |
261+
| [aws_ssoadmin_application_assignment.sso_apps_groups_assignments](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_application_assignment) | resource |
262+
| [aws_ssoadmin_application_assignment.sso_apps_users_assignments](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_application_assignment) | resource |
263+
| [aws_ssoadmin_application_assignment_configuration.sso_apps_assignments_configs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_application_assignment_configuration) | resource |
202264
| [aws_ssoadmin_customer_managed_policy_attachment.pset_customer_managed_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_customer_managed_policy_attachment) | resource |
203265
| [aws_ssoadmin_managed_policy_attachment.pset_aws_managed_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_managed_policy_attachment) | resource |
204266
| [aws_ssoadmin_permission_set.pset](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_permission_set) | resource |
@@ -222,6 +284,7 @@ No modules.
222284
| <a name="input_existing_sso_groups"></a> [existing\_sso\_groups](#input\_existing\_sso\_groups) | Names of the existing groups that you wish to reference from IAM Identity Center. | <pre>map(object({<br> group_name = string<br> }))</pre> | `{}` | no |
223285
| <a name="input_existing_sso_users"></a> [existing\_sso\_users](#input\_existing\_sso\_users) | Names of the existing users that you wish to reference from IAM Identity Center. | <pre>map(object({<br> user_name = string<br> group_membership = optional(list(string), null) // only used if your IdP only syncs users, and you wish to manage which groups they should go in<br> }))</pre> | `{}` | no |
224286
| <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 |
287+
| <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 |
225288
| <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 |
226289
| <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 |
227290

@@ -231,5 +294,8 @@ No modules.
231294
|------|-------------|
232295
| <a name="output_account_assignment_data"></a> [account\_assignment\_data](#output\_account\_assignment\_data) | Tuple containing account assignment data |
233296
| <a name="output_principals_and_assignments"></a> [principals\_and\_assignments](#output\_principals\_and\_assignments) | Map containing account assignment data |
297+
| <a name="output_sso_applications_arns"></a> [sso\_applications\_arns](#output\_sso\_applications\_arns) | A map of SSO Applications ARNs created by this module |
298+
| <a name="output_sso_applications_group_assignments"></a> [sso\_applications\_group\_assignments](#output\_sso\_applications\_group\_assignments) | A map of SSO Applications assignments with groups created by this module |
299+
| <a name="output_sso_applications_user_assignments"></a> [sso\_applications\_user\_assignments](#output\_sso\_applications\_user\_assignments) | A map of SSO Applications assignments with users created by this module |
234300
| <a name="output_sso_groups_ids"></a> [sso\_groups\_ids](#output\_sso\_groups\_ids) | A map of SSO groups ids created by this module |
235301
<!-- END_TF_DOCS -->

VERSION

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
v1.0.0
1+
v1.0.1
2+
3+

data.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,3 @@ data "aws_ssoadmin_permission_set" "existing_permission_sets" {
9898
# permission_sets = "ViewOnlyAccess"
9999
# account_ids = "111111111111"
100100
# }
101-
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
This directory contains examples of using the module to **create** applications, application assignments configurations, users, groups and application assignments to both users and groups
2+
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 'Admin' and 'nuzumaki':
4+
5+
```hcl
6+
sso_groups = {
7+
Admin : {
8+
group_name = "Admin"
9+
group_description = "Admin IAM Identity Center Group"
10+
},
11+
}
12+
13+
// Create desired USERS in IAM Identity Center
14+
sso_users = {
15+
nuzumaki : {
16+
group_membership = ["Admin",]
17+
user_name = "nuzumaki"
18+
given_name = "Naruto"
19+
family_name = "Uzumaki"
20+
email = "nuzumaki@hiddenleaf.village"
21+
},
22+
}
23+
24+
// Create desired Applications in IAM Identity Center
25+
sso_applications = {
26+
FirstApplication : {
27+
application_provider_arn = "arn:aws:sso::aws:applicationProvider/custom"
28+
description = "I am the First Application"
29+
name = "FirstApplication"
30+
portal_options = {
31+
sign_in_options = {
32+
application_url = "http://example.com"
33+
origin = "APPLICATION"
34+
}
35+
visibility = "ENABLED"
36+
}
37+
status = "ENABLED"
38+
assignment_required = true
39+
assignments_access_scope = [
40+
{
41+
authorized_targets = ["FirstApplication"]
42+
scope = "sso:account:access"
43+
}
44+
]
45+
group_assignments = ["Dev"]
46+
user_assignments = ["nuzumaki"]
47+
}
48+
}
49+
50+
```
51+
52+
These names are referenced throughout the module. Failure to do this may lead to unintentional errors such as the following:
53+
54+
```
55+
Error: Invalid index
56+
57+
│ on ../../main.tf line 141, in resource "aws_identitystore_group_membership" "sso_group_membership":
58+
│ 141: member_id = (contains(local.this_users, each.value.user_name) ? aws_identitystore_user.sso_users[each.value.user_name].user_id : data.aws_identitystore_user.existing_sso_users[each.value.user_name].id)
59+
│ ├────────────────
60+
│ │ aws_identitystore_user.sso_users is object with 2 attributes
61+
│ │ each.value.user_name is "nuzumaki"
62+
63+
│ The given key does not identify an element in this collection value.
64+
```
65+
66+
To resolve this, ensure your object and principal names are the same and re-run `terraform plan` and `terraform apply`.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<!-- BEGIN_TF_DOCS -->
2+
This directory contains examples of using the module to **create** applications, application assignments configurations, users, groups and application assignments to both users and groups
3+
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 'Admin' and 'nuzumaki':
5+
6+
```hcl
7+
sso_groups = {
8+
Admin : {
9+
group_name = "Admin"
10+
group_description = "Admin IAM Identity Center Group"
11+
},
12+
}
13+
14+
// Create desired USERS in IAM Identity Center
15+
sso_users = {
16+
nuzumaki : {
17+
group_membership = ["Admin",]
18+
user_name = "nuzumaki"
19+
given_name = "Naruto"
20+
family_name = "Uzumaki"
21+
email = "nuzumaki@hiddenleaf.village"
22+
},
23+
}
24+
25+
// Create desired Applications in IAM Identity Center
26+
sso_applications = {
27+
FirstApplication : {
28+
application_provider_arn = "arn:aws:sso::aws:applicationProvider/custom"
29+
description = "I am the First Application"
30+
name = "FirstApplication"
31+
portal_options = {
32+
sign_in_options = {
33+
application_url = "http://example.com"
34+
origin = "APPLICATION"
35+
}
36+
visibility = "ENABLED"
37+
}
38+
status = "ENABLED"
39+
assignment_required = true
40+
assignments_access_scope = [
41+
{
42+
authorized_targets = ["FirstApplication"]
43+
scope = "sso:account:access"
44+
}
45+
]
46+
group_assignments = ["Dev"]
47+
user_assignments = ["nuzumaki"]
48+
}
49+
}
50+
51+
```
52+
53+
These names are referenced throughout the module. Failure to do this may lead to unintentional errors such as the following:
54+
55+
```
56+
Error: Invalid index
57+
58+
│ on ../../main.tf line 141, in resource "aws_identitystore_group_membership" "sso_group_membership":
59+
│ 141: member_id = (contains(local.this_users, each.value.user_name) ? aws_identitystore_user.sso_users[each.value.user_name].user_id : data.aws_identitystore_user.existing_sso_users[each.value.user_name].id)
60+
│ ├────────────────
61+
│ │ aws_identitystore_user.sso_users is object with 2 attributes
62+
│ │ each.value.user_name is "nuzumaki"
63+
64+
│ The given key does not identify an element in this collection value.
65+
```
66+
67+
To resolve this, ensure your object and principal names are the same and re-run `terraform plan` and `terraform apply`.
68+
69+
## Requirements
70+
71+
No requirements.
72+
73+
## Providers
74+
75+
| Name | Version |
76+
|------|---------|
77+
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
78+
79+
## Modules
80+
81+
| Name | Source | Version |
82+
|------|--------|---------|
83+
| <a name="module_aws-iam-identity-center"></a> [aws-iam-identity-center](#module\_aws-iam-identity-center) | ../.. | n/a |
84+
85+
## Resources
86+
87+
| Name | Type |
88+
|------|------|
89+
| [aws_ssm_parameter.account1_account_id](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
90+
91+
## Inputs
92+
93+
No inputs.
94+
95+
## Outputs
96+
97+
No outputs.
98+
<!-- END_TF_DOCS -->
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Fetch Account Id from SSM Parameter Store
2+
data "aws_ssm_parameter" "account1_account_id" {
3+
name = "tf-aws-iam-idc-module-testing-account1-account-id" // replace with your SSM Parameter Key
4+
}
5+
6+
locals {
7+
# Account IDs
8+
account1_account_id = nonsensitive(data.aws_ssm_parameter.account1_account_id.value)
9+
# account1_account_id = "111111111111"
10+
# account2_account_id = "222222222222"
11+
# account3_account_id = "333333333333"
12+
# account4_account_id = "444444444444"
13+
14+
}

0 commit comments

Comments
 (0)