forked from mhmdio/terraform-aws-sso
-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.tf
32 lines (29 loc) · 1.31 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
resource "aws_ssoadmin_account_assignment" "this" {
for_each = { for i, v in var.account_assignments : i => v }
instance_arn = aws_ssoadmin_permission_set.this.instance_arn
permission_set_arn = aws_ssoadmin_permission_set.this.arn
principal_id = data.aws_identitystore_group.this[each.value.group_display_name].group_id
principal_type = "GROUP"
target_type = "AWS_ACCOUNT"
target_id = each.value.account_id
}
resource "aws_ssoadmin_permission_set" "this" {
name = var.name
description = var.description
instance_arn = local.sso_instance_arn
relay_state = var.relay_state
session_duration = var.session_duration
tags = var.tags
}
resource "aws_ssoadmin_managed_policy_attachment" "this" {
count = length(var.managed_policy_arns)
instance_arn = aws_ssoadmin_permission_set.this.instance_arn
permission_set_arn = aws_ssoadmin_permission_set.this.arn
managed_policy_arn = var.managed_policy_arns[count.index]
}
resource "aws_ssoadmin_permission_set_inline_policy" "this" {
count = length(var.inline_policy) > 0 ? 1 : 0
inline_policy = var.inline_policy
instance_arn = aws_ssoadmin_permission_set.this.instance_arn
permission_set_arn = aws_ssoadmin_permission_set.this.arn
}