diff --git a/main.tf b/main.tf index 9941ae6..3482932 100644 --- a/main.tf +++ b/main.tf @@ -16,6 +16,7 @@ module "eks" { module "permission_sets" { source = "./modules/iam_identity_center" + aws_account = var.aws_account permission_sets = [ { diff --git a/modules/iam_identity_center/main.tf b/modules/iam_identity_center/main.tf index 96a6dff..ed29c62 100644 --- a/modules/iam_identity_center/main.tf +++ b/modules/iam_identity_center/main.tf @@ -94,13 +94,13 @@ resource "aws_identitystore_group_membership" "this" { member_id = aws_identitystore_user.this[each.key].user_id } -# resource "aws_ssoadmin_account_assignment" "this" { -# instance_arn = tolist(data.aws_ssoadmin_instances.this.arns)[0] -# permission_set_arn = data.aws_ssoadmin_permission_set.this.arn +resource "aws_ssoadmin_account_assignment" "this" { + instance_arn = tolist(data.aws_ssoadmin_instances.this.arns)[0] + permission_set_arn = aws_ssoadmin_permission_set.this[each.value.policy_set].arn -# principal_id = data.aws_identitystore_group.this.group_id -# principal_type = "GROUP" + principal_id = aws_identitystore_group.this[each.value.groups].group_id + principal_type = "GROUP" -# target_id = "123456789012" -# target_type = "AWS_ACCOUNT" -# } + target_id = var.aws_account + target_type = "AWS_ACCOUNT" +} diff --git a/modules/iam_identity_center/variables.tf b/modules/iam_identity_center/variables.tf index a7ab3b3..269140c 100644 --- a/modules/iam_identity_center/variables.tf +++ b/modules/iam_identity_center/variables.tf @@ -36,4 +36,8 @@ variable "groups" { description = "List of IAM identity center groups to create" type = set(string) default = [] -} \ No newline at end of file +} + +variable "aws_account" { + description = "Account number to create aws resources in. This variable should be defined in the terraform cloud workspace settings" +}