Skip to content

Commit 7cd7927

Browse files
authored
enhancement: user_access module now supports passing in aws account ids to set up trust policies so users in different accounts can assume the roles we create (#50)
1 parent 2edb24b commit 7cd7927

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

modules/user_access/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ Create IAM Roles/Groups and Kubernetes Cluster Roles for user access
2222

2323
| Name | Description | Type | Default | Required |
2424
|------|-------------|------|---------|:--------:|
25+
| assumerole\_account\_ids | AWS account IDs that will be allowed to assume the roles we are creating. If left blank, the AWS account you are using will be used | `list(string)` | `[]` | no |
2526
| environment | The environment (stage/prod) | `any` | n/a | yes |
2627
| project | Name of the project | `any` | n/a | yes |
27-
| roles | Role list with policies | <pre>list(object({<br> name = string<br> aws_policy = string<br> k8s_policies = list(map(list(string)))<br> }))</pre> | n/a | yes |
28-
| users | User list with roles | <pre>list(object({<br> name = string<br> roles = list(string)<br> }))</pre> | n/a | yes |
28+
| roles | Roles to create with associated aws and k8s policies | <pre>list(object({<br> name = string<br> aws_policy = string<br> k8s_policies = list(map(list(string)))<br> }))</pre> | n/a | yes |
29+
| users | Users to create with associated roles, mapping to the ones defined in the roles variable | <pre>list(object({<br> name = string<br> roles = list(string)<br> }))</pre> | n/a | yes |
2930

3031
## Outputs
3132

modules/user_access/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ data "aws_iam_policy_document" "access_assumerole_root_policy" {
7979

8080
principals {
8181
type = "AWS"
82-
identifiers = [local.account_id]
82+
identifiers = var.assumerole_account_ids == [] ? [local.account_id] : var.assumerole_account_ids
8383
}
8484
}
8585
}

modules/user_access/variables.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ variable "environment" {
77
}
88

99
variable "roles" {
10+
description = "Roles to create with associated aws and k8s policies"
1011
type = list(object({
1112
name = string
1213
aws_policy = string
1314
k8s_policies = list(map(list(string)))
1415
}))
15-
description = "Role list with policies"
1616
}
1717

1818
variable "users" {
19+
description = "Users to create with associated roles, mapping to the ones defined in the roles variable"
1920
type = list(object({
2021
name = string
2122
roles = list(string)
2223
}))
23-
description = "User list with roles"
24+
}
25+
26+
variable "assumerole_account_ids" {
27+
description = "AWS account IDs that will be allowed to assume the roles we are creating. If left blank, the AWS account you are using will be used"
28+
type = list(string)
29+
default = []
2430
}

0 commit comments

Comments
 (0)