Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add in users module #7

Merged
merged 6 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,20 @@ module "eks" {

subnet_ids = module.network.private_subnet_ids
control_plane_subnet_ids = module.network.private_subnet_ids
}

module "permission_sets" {
source = "./modules/iam_identity_center"

permission_sets = [
{
name = "AdministratorAccess",
description = "Allow full access to the account",
relay_state = "",
session_duration = "",
tags = {},
inline_policy = "",
policy_attachments = ["arn:aws:iam::aws:policy/AdministratorAccess"]
customer_managed_policy_attachments = []
}]
}
4 changes: 0 additions & 4 deletions modules/iam_identity_center/variables.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
variable "aws_account" {
description = "Account number to create aws resources in. This variable should be defined in the terraform cloud workspace settings"
}

variable "permission_sets" {
type = list(object({
name = string
Expand Down
20 changes: 20 additions & 0 deletions modules/iam_identity_users/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
data "aws_ssoadmin_instances" "this" {}


resource "aws_identitystore_user" "this" {
for_each = var.users

identity_store_id = tolist(data.aws_ssoadmin_instances.this.identity_store_ids)[0]

display_name = format("%s %s", each.value.first_name, each.value.last_name)
user_name = format("%s%s", substr(lower(each.value.first_name), 0, 1), lower(each.value.last_name))

name {
given_name = each.value.first_name
family_name = each.value.last_name
}

emails {
value = join("@", [format("%s.%s", lower(each.value.first_name), lower(each.value.last_name)), var.email_domain])
}
}
13 changes: 13 additions & 0 deletions modules/iam_identity_users/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
variable "users" {
description = "Map of user identifiers to user details including their team."
type = map(object({
first_name = string
last_name = string
}))
}

variable "email_domain" {
description = "Domain used for user email accounts"
type = string
default = "example.com"
}
13 changes: 13 additions & 0 deletions users.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module "users" {
source = "./modules/iam_identity_users"
users = {
"Zach Rundle" = {
first_name = "Zach"
last_name = "Rundle"
},
"Maverick Dog" = {
first_name = "Maverick"
last_name = "Dog"
},
}
}