forked from zoitech/terraform-aws-saml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam_roles.tf
30 lines (29 loc) · 869 Bytes
/
iam_roles.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
resource "aws_iam_role" "delegate_user" {
count = length(local.roles)
name = lookup(element(local.roles, count.index), "role_name")
description = lookup(element(local.roles, count.index), "role_description")
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "${aws_iam_saml_provider.saml.id}"
},
"Action": "sts:AssumeRoleWithSAML",
"Condition": {
"StringEquals": {
"SAML:aud": "https://signin.aws.amazon.com/saml"
}
}
}
]
}
EOF
}
resource "aws_iam_role_policy_attachment" "delegate_user_attachment" {
count = length(local.roles)
role = aws_iam_role.delegate_user[count.index].name
policy_arn = lookup(element(local.roles, count.index), "role_policy_arn")
}