Skip to content

Commit 1158904

Browse files
authored
feat: create aws-sso groups for google workspaces (cloudposse/terraform-aws-components#928)
1 parent 2dd73ef commit 1158904

File tree

4 files changed

+103
-39
lines changed

4 files changed

+103
-39
lines changed

src/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,28 @@ delegating SSO to the `identity` account is lost.
2626
Nevertheless, it is also not worth the effort to remove the delegation. If you have already delegated SSO to the `identity`,
2727
continue on, leaving the stack configuration in the `gbl-identity` stack rather than the currently recommended `gbl-root` stack.
2828

29+
### Google Workspace
30+
31+
:::important
32+
33+
> Your identity source is currently configured as 'External identity provider'. To add new groups or edit their memberships, you must do this using your external identity provider.
34+
35+
Groups _cannot_ be created with ClickOps in the AWS console and instead must be created with AWS API.
36+
37+
:::
38+
39+
Google Workspace is now supported by AWS Identity Center, but Group creation is not automatically handled. After [configuring SAML and SCIM with Google Workspace and IAM Identity Center following the AWS documentation](https://docs.aws.amazon.com/singlesignon/latest/userguide/gs-gwp.html), add any Group name to `var.groups` to create the Group with Terraform. Once the setup steps as described in the AWS documentation have been completed and the Groups are created with Terraform, Users should automatically populate each created Group.
40+
41+
```yaml
42+
components:
43+
terraform:
44+
aws-sso:
45+
vars:
46+
groups:
47+
- "Developers"
48+
- "Dev Ops"
49+
```
50+
2951
### Atmos
3052
3153
**Stack Level**: Global
@@ -187,11 +209,13 @@ components:
187209

188210
| Name | Type |
189211
|------|------|
212+
| [aws_identitystore_group.manual](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/identitystore_group) | resource |
190213
| [aws_iam_policy_document.assume_aws_team](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
191214
| [aws_iam_policy_document.dns_administrator_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
192215
| [aws_iam_policy_document.eks_read_only](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
193216
| [aws_iam_policy_document.terraform_update_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
194217
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
218+
| [aws_ssoadmin_instances.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssoadmin_instances) | data source |
195219

196220
## Inputs
197221

@@ -206,6 +230,7 @@ components:
206230
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
207231
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
208232
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
233+
| <a name="input_groups"></a> [groups](#input\_groups) | List of AWS Identity Center Groups to be created with the AWS API.<br><br>When provisioning the Google Workspace Integration with AWS, Groups need to be created with API in order for automatic provisioning to work as intended. | `list(string)` | `[]` | no |
209234
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
210235
| <a name="input_label_key_case"></a> [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.<br>Does not affect keys of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper`.<br>Default value: `title`. | `string` | `null` | no |
211236
| <a name="input_label_order"></a> [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no |
@@ -225,6 +250,7 @@ components:
225250

226251
| Name | Description |
227252
|------|-------------|
253+
| <a name="output_group_ids"></a> [group\_ids](#output\_group\_ids) | Group IDs created for Identity Center |
228254
| <a name="output_permission_sets"></a> [permission\_sets](#output\_permission\_sets) | Permission sets |
229255
| <a name="output_sso_account_assignments"></a> [sso\_account\_assignments](#output\_sso\_account\_assignments) | SSO account assignments |
230256
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

src/main.tf

Lines changed: 62 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,3 @@
1-
module "permission_sets" {
2-
source = "cloudposse/sso/aws//modules/permission-sets"
3-
version = "1.1.1"
4-
5-
permission_sets = concat(
6-
local.overridable_additional_permission_sets,
7-
local.administrator_access_permission_set,
8-
local.billing_administrator_access_permission_set,
9-
local.billing_read_only_access_permission_set,
10-
local.dns_administrator_access_permission_set,
11-
local.identity_access_permission_sets,
12-
local.poweruser_access_permission_set,
13-
local.read_only_access_permission_set,
14-
local.terraform_update_access_permission_set,
15-
)
16-
17-
context = module.this.context
18-
}
19-
20-
module "sso_account_assignments" {
21-
source = "cloudposse/sso/aws//modules/account-assignments"
22-
version = "1.1.1"
23-
24-
account_assignments = local.account_assignments
25-
context = module.this.context
26-
}
27-
28-
module "sso_account_assignments_root" {
29-
source = "cloudposse/sso/aws//modules/account-assignments"
30-
version = "1.1.1"
31-
32-
providers = {
33-
aws = aws.root
34-
}
35-
36-
account_assignments = local.account_assignments_root
37-
context = module.this.context
38-
}
39-
401
locals {
412
enabled = module.this.enabled
423

@@ -99,4 +60,66 @@ locals {
9960
aws_partition = data.aws_partition.current.partition
10061
}
10162

63+
data "aws_ssoadmin_instances" "this" {}
64+
10265
data "aws_partition" "current" {}
66+
67+
resource "aws_identitystore_group" "manual" {
68+
for_each = toset(var.groups)
69+
70+
display_name = each.key
71+
description = "Group created with Terraform"
72+
73+
identity_store_id = tolist(data.aws_ssoadmin_instances.this.identity_store_ids)[0]
74+
}
75+
76+
module "permission_sets" {
77+
source = "cloudposse/sso/aws//modules/permission-sets"
78+
version = "1.1.1"
79+
80+
permission_sets = concat(
81+
local.overridable_additional_permission_sets,
82+
local.administrator_access_permission_set,
83+
local.billing_administrator_access_permission_set,
84+
local.billing_read_only_access_permission_set,
85+
local.dns_administrator_access_permission_set,
86+
local.identity_access_permission_sets,
87+
local.poweruser_access_permission_set,
88+
local.read_only_access_permission_set,
89+
local.terraform_update_access_permission_set,
90+
)
91+
92+
context = module.this.context
93+
94+
depends_on = [
95+
aws_identitystore_group.manual
96+
]
97+
}
98+
99+
module "sso_account_assignments" {
100+
source = "cloudposse/sso/aws//modules/account-assignments"
101+
version = "1.1.1"
102+
103+
account_assignments = local.account_assignments
104+
context = module.this.context
105+
106+
depends_on = [
107+
aws_identitystore_group.manual
108+
]
109+
}
110+
111+
module "sso_account_assignments_root" {
112+
source = "cloudposse/sso/aws//modules/account-assignments"
113+
version = "1.1.1"
114+
115+
providers = {
116+
aws = aws.root
117+
}
118+
119+
account_assignments = local.account_assignments_root
120+
context = module.this.context
121+
122+
depends_on = [
123+
aws_identitystore_group.manual
124+
]
125+
}

src/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ output "sso_account_assignments" {
77
value = module.sso_account_assignments.assignments
88
description = "SSO account assignments"
99
}
10+
11+
output "group_ids" {
12+
value = { for group_key, group_output in aws_identitystore_group.manual : group_key => group_output.group_id }
13+
description = "Group IDs created for Identity Center"
14+
}

src/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,13 @@ variable "aws_teams_accessible" {
4242
EOT
4343
default = []
4444
}
45+
46+
variable "groups" {
47+
type = list(string)
48+
description = <<-EOT
49+
List of AWS Identity Center Groups to be created with the AWS API.
50+
51+
When provisioning the Google Workspace Integration with AWS, Groups need to be created with API in order for automatic provisioning to work as intended.
52+
EOT
53+
default = []
54+
}

0 commit comments

Comments
 (0)