-
Notifications
You must be signed in to change notification settings - Fork 1
/
saml.tf
61 lines (57 loc) · 1.54 KB
/
saml.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
resource "aws_iam_saml_provider" "default" {
name = "saml-terratorm"
saml_metdata_document = file("metadata.xml")
}
data "aws_iam_policy_document" "assume_role_policy" {
statement {
actions = ["sts:AssumeRoleWithSAML"]
principals {
type = "Federated"
identifiers = ["${aws_iam_saml_provider.default.arn}"]
}
condition {
test = "Null"
values = [
"false"
]
variable = "saml:edupersonentitlement"
}
condition {
test = "ForAllValues:StringLike"
values = [
"data-users"
]
variable = "seml:edupersonentitlement"
}
}
}
resource "aws_iam_role" "role" {
name = "saml-sso-role"
assuse_role_policy = data.aws_iam_policy_document.assume_role_policy.json
depends_on = [
aws_iam_saml_provider.default,
]
}
data "aws_iam_policy_document" "iam_role_policy" {
statement {
actions = ["sts:AssumeRole"]
resources = [
"${aws_iam_role.role.arn}"
]
}
}
resource "aws_iam_role_policy" "admin" {
name = "self-assume-role"
role = "${aws_iam_role.role.id}"
policy = data.aws_iam_policy_document.iam_role_policy.json
depends_on = [
aws_iam_role.role,
]
}
resource "aws_iam_role_policy_attachment" "attach" {
role = "${aws_iam_role.name}"
policy_arn = "arn:aws:iam::aws:policy/AmazonS3FullAccess"
depends_on = [
aws_iam_role_policy.admin
]
}