-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.tf
More file actions
93 lines (73 loc) · 1.9 KB
/
main.tf
File metadata and controls
93 lines (73 loc) · 1.9 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
resource "aws_iam_saml_provider" "this" {
for_each = toset(keys(var.saml_providers))
name = each.value
saml_metadata_document = var.saml_providers[each.value]
}
data "aws_iam_policy_document" "this" {
statement {
effect = "Allow"
actions = [
"iam:ListAccountAliases",
"iam:ListRoles"
]
resources = ["*"]
}
}
resource "aws_iam_group" "this" {
name = var.iam_group_name
path = "/"
}
resource "aws_iam_group_policy" "this" {
name_prefix = "terraform-okta-sso"
group = aws_iam_group.this.id
policy = data.aws_iam_policy_document.this.json
}
resource "aws_iam_user" "this" {
count = var.create_okta_iam_user ? 1 : 0
name = var.iam_user_name
path = "/"
tags = var.tags
}
resource "aws_iam_user_group_membership" "this" {
count = var.create_okta_iam_user ? 1 : 0
user = aws_iam_user.this[0].name
groups = [
aws_iam_group.this.name
]
}
resource "aws_iam_access_key" "this" {
count = var.create_okta_iam_user ? 1 : 0
user = aws_iam_user.this[0].name
}
resource "aws_secretsmanager_secret" "this" {
count = var.create_okta_iam_user ? 1 : 0
name_prefix = "terraform-okta-sso"
description = "Okta SSO user access key"
kms_key_id = var.kms_key_id
tags = var.tags
}
resource "aws_secretsmanager_secret_version" "this" {
count = var.create_okta_iam_user ? 1 : 0
secret_id = aws_secretsmanager_secret.this[0].id
secret_string = aws_iam_access_key.this[0].secret
}
moved {
from = aws_iam_user.this
to = aws_iam_user.this[0]
}
moved {
from = aws_iam_user_group_membership.this
to = aws_iam_user_group_membership.this[0]
}
moved {
from = aws_iam_access_key.this
to = aws_iam_access_key.this[0]
}
moved {
from = aws_secretsmanager_secret.this
to = aws_secretsmanager_secret.this[0]
}
moved {
from = aws_secretsmanager_secret_version.this
to = aws_secretsmanager_secret_version.this[0]
}