Skip to content

Commit 92d4e76

Browse files
committed
add support for: IAM IdC Applications (with testing)
1 parent 7536bb4 commit 92d4e76

File tree

15 files changed

+724
-2
lines changed

15 files changed

+724
-2
lines changed

.header.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
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)
15+
1416

1517
## Important
1618

@@ -37,6 +39,32 @@
3739
},
3840
}
3941
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+
4068
```
4169

4270
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 +195,34 @@ module "aws-iam-identity-center" {
167195
}
168196
```
169197

198+
## Basic Usage - Create Applications and assign to Users and Groups
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+
```
170226
## Contributing
171227

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

README.md

Lines changed: 65 additions & 1 deletion
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,34 @@ module "aws-iam-identity-center" {
168195
}
169196
```
170197

198+
## Basic Usage - Create Applications and assign to Users and Groups
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+
```
171226
## Contributing
172227

173228
See the `CONTRIBUTING.md` file for information on how to contribute.
@@ -184,7 +239,7 @@ See the `CONTRIBUTING.md` file for information on how to contribute.
184239

185240
| Name | Version |
186241
|------|---------|
187-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.35.0 |
242+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.73.0 |
188243

189244
## Modules
190245

@@ -199,6 +254,11 @@ No modules.
199254
| [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 |
200255
| [aws_identitystore_user.sso_users](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/identitystore_user) | resource |
201256
| [aws_ssoadmin_account_assignment.account_assignment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_account_assignment) | resource |
257+
| [aws_ssoadmin_application.sso_apps](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_application) | resource |
258+
| [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 |
259+
| [aws_ssoadmin_application_assignment.sso_apps_groups_assignments](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_application_assignment) | resource |
260+
| [aws_ssoadmin_application_assignment.sso_apps_users_assignments](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_application_assignment) | resource |
261+
| [aws_ssoadmin_application_assignment_configuration.sso_apps_assignments_configs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_application_assignment_configuration) | resource |
202262
| [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 |
203263
| [aws_ssoadmin_managed_policy_attachment.pset_aws_managed_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_managed_policy_attachment) | resource |
204264
| [aws_ssoadmin_permission_set.pset](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_permission_set) | resource |
@@ -222,6 +282,7 @@ No modules.
222282
| <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 |
223283
| <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 |
224284
| <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 |
285+
| <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 |
225286
| <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 |
226287
| <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 |
227288

@@ -231,5 +292,8 @@ No modules.
231292
|------|-------------|
232293
| <a name="output_account_assignment_data"></a> [account\_assignment\_data](#output\_account\_assignment\_data) | Tuple containing account assignment data |
233294
| <a name="output_principals_and_assignments"></a> [principals\_and\_assignments](#output\_principals\_and\_assignments) | Map containing account assignment data |
295+
| <a name="output_sso_applications_arns"></a> [sso\_applications\_arns](#output\_sso\_applications\_arns) | A map of SSO Applications ARNs created by this module |
296+
| <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 |
297+
| <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 |
234298
| <a name="output_sso_groups_ids"></a> [sso\_groups\_ids](#output\_sso\_groups\_ids) | A map of SSO groups ids created by this module |
235299
<!-- END_TF_DOCS -->

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: 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)