Skip to content

Commit 627435a

Browse files
committed
add in users module
1 parent 5a0f4fa commit 627435a

File tree

5 files changed

+61
-4
lines changed

5 files changed

+61
-4
lines changed

main.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,20 @@ module "eks" {
1212

1313
subnet_ids = module.network.private_subnet_ids
1414
control_plane_subnet_ids = module.network.private_subnet_ids
15+
}
16+
17+
module "permission_sets" {
18+
source = "./modules/iam_identity_center"
19+
20+
permission_sets = [
21+
{
22+
name = "AdministratorAccess",
23+
description = "Allow full access to the account",
24+
relay_state = "",
25+
session_duration = "",
26+
tags = {},
27+
inline_policy = "",
28+
policy_attachments = ["arn:aws:iam::aws:policy/AdministratorAccess"]
29+
customer_managed_policy_attachments = []
30+
}]
1531
}

modules/iam_identity_center/variables.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
variable "aws_account" {
2-
description = "Account number to create aws resources in. This variable should be defined in the terraform cloud workspace settings"
3-
}
4-
51
variable "permission_sets" {
62
type = list(object({
73
name = string

modules/iam_identity_users/main.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
data "aws_ssoadmin_instances" "this" {}
2+
3+
4+
5+
resource "aws_identitystore_user" "this" {
6+
identity_store_id = tolist(data.aws_ssoadmin_instances.this.identity_store_ids)[0]
7+
8+
display_name = format("%s %s", each.value.first_name, each.value.last_name)
9+
user_name = format("%s%s", substr(lower(each.value.first_name), 0, 1), lower(each.value.last_name))
10+
11+
name {
12+
given_name = each.value.first_name
13+
family_name = each.value.last_name
14+
}
15+
16+
emails {
17+
value = join("@", [format("%s.%s", lower(each.value.first_name), lower(each.value.last_name)), var.email_domain])
18+
}
19+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
variable "users" {
2+
description = "Map of user identifiers to user details including their team."
3+
type = map(object({
4+
first_name = string
5+
last_name = string
6+
}))
7+
}
8+
9+
variable "email_domain" {
10+
description = "Domain of the company"
11+
type = string
12+
default = "example.com"
13+
}

users.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module "users" {
2+
source = "./modules/iam_identity_users"
3+
users = {
4+
"user" = {
5+
first_name = "Zach"
6+
last_name = "Rundle"
7+
},
8+
"user" = {
9+
first_name = "Maverick"
10+
last_name = "Dog"
11+
},
12+
}
13+
}

0 commit comments

Comments
 (0)