Skip to content

Commit 067084a

Browse files
authored
Merge pull request #50 from dtappert/add-instance-access-control-attributes
Add instance access control attributes
2 parents 2d02931 + 49bb6cf commit 067084a

File tree

11 files changed

+149
-4
lines changed

11 files changed

+149
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ No modules.
262262
| [aws_ssoadmin_application_assignment.sso_apps_users_assignments](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_application_assignment) | resource |
263263
| [aws_ssoadmin_application_assignment_configuration.sso_apps_assignments_configs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_application_assignment_configuration) | resource |
264264
| [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 |
265+
| [aws_ssoadmin_instance_access_control_attributes.sso_access_control_attributes](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_instance_access_control_attributes) | resource |
265266
| [aws_ssoadmin_managed_policy_attachment.pset_aws_managed_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_managed_policy_attachment) | resource |
266267
| [aws_ssoadmin_permission_set.pset](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_permission_set) | resource |
267268
| [aws_ssoadmin_permission_set_inline_policy.pset_inline_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssoadmin_permission_set_inline_policy) | resource |
@@ -286,6 +287,7 @@ No modules.
286287
| <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 |
287288
| <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 |
288289
| <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>list(object({<br> attribute_name = string<br> source = set(string)<br> }))</pre> | `[]` | no |
289291
| <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 |
290292

291293
## Outputs

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
v1.0.1
1+
v1.0.2
22

33

examples/inline-policy/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module "aws-iam-identity-center" {
5252

5353
existing_sso_groups = {
5454
AWSControlTowerAdmins : {
55-
group_name = "AWSControlTowerAdmins"
55+
group_name = "AWSControlTowerAdmins" # this must be the name of a sso group that already exists in your AWS account
5656
}
5757
}
5858

@@ -85,7 +85,7 @@ module "aws-iam-identity-center" {
8585

8686
existing_permission_sets = {
8787
AWSAdministratorAccess : {
88-
permission_set_name = "AWSAdministratorAccess"
88+
permission_set_name = "AWSAdministratorAccess" # this must be the name of a permission set that already exists in your AWS account
8989
},
9090
}
9191

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
This directory contains examples of using the module to **create** instance access control attributes.
2+
3+
```hcl
4+
sso_instance_access_control_attributes = [
5+
{
6+
attribute_name = "FirstName"
7+
source = ["$${path:name.givenName}"]
8+
},
9+
{
10+
attribute_name = "LastName"
11+
source = ["$${path:name.familyName}"]
12+
}
13+
]
14+
```
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!-- BEGIN_TF_DOCS -->
2+
This directory contains examples of using the module to **create** instance access control attributes.
3+
4+
```hcl
5+
sso_instance_access_control_attributes = [
6+
{
7+
attribute_name = "FirstName"
8+
source = ["$${path:name.givenName}"]
9+
},
10+
{
11+
attribute_name = "LastName"
12+
source = ["$${path:name.familyName}"]
13+
}
14+
]
15+
```
16+
17+
## Requirements
18+
19+
No requirements.
20+
21+
## Providers
22+
23+
| Name | Version |
24+
|------|---------|
25+
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
26+
27+
## Modules
28+
29+
| Name | Source | Version |
30+
|------|--------|---------|
31+
| <a name="module_aws-iam-identity-center"></a> [aws-iam-identity-center](#module\_aws-iam-identity-center) | ../.. | n/a |
32+
33+
## Resources
34+
35+
| Name | Type |
36+
|------|------|
37+
| [aws_ssm_parameter.account1_account_id](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
38+
39+
## Inputs
40+
41+
No inputs.
42+
43+
## Outputs
44+
45+
No outputs.
46+
<!-- 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+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module "aws-iam-identity-center" {
2+
source = "../.." // local example
3+
4+
//Create desired access control attributes
5+
sso_instance_access_control_attributes = [
6+
{
7+
attribute_name = "FirstName"
8+
source = ["$${path:name.givenName}"]
9+
},
10+
{
11+
attribute_name = "LastName"
12+
source = ["$${path:name.familyName}"]
13+
}
14+
]
15+
}

main.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,17 @@ resource "aws_ssoadmin_application_assignment" "sso_apps_users_assignments" {
318318
principal_type = each.value.principal_type
319319
}
320320

321+
# SSO Instance Access Control Attributes
322+
resource "aws_ssoadmin_instance_access_control_attributes" "sso_access_control_attributes" {
323+
count = length(var.sso_instance_access_control_attributes) <= 0 ? 0 : 1
324+
instance_arn = local.ssoadmin_instance_arn
325+
dynamic "attribute" {
326+
for_each = var.sso_instance_access_control_attributes
327+
content {
328+
key = attribute.key
329+
value {
330+
source = attribute.value.source
331+
}
332+
}
333+
}
334+
}

tests/01_mandatory.tftest.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ run "e2e_test" {
1010
module {
1111
source = "./examples/create-users-and-groups"
1212
}
13-
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
run "unit_test" {
2+
command = plan
3+
module {
4+
source = "./examples/instance-access-control-attributes"
5+
}
6+
}
7+
8+
run "e2e_test" {
9+
command = apply
10+
module {
11+
source = "./examples/instance-access-control-attributes"
12+
}
13+
}

0 commit comments

Comments
 (0)