-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathec2_policy.tf
More file actions
58 lines (47 loc) · 1.56 KB
/
ec2_policy.tf
File metadata and controls
58 lines (47 loc) · 1.56 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
data "aws_iam_policy_document" "ec2_assume_role" {
statement {
actions = ["sts:AssumeRole"]
effect = "Allow"
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
}
}
resource "aws_iam_role" "controller" {
name = "resinstack-boundary-controller-${var.cluster_tag}"
assume_role_policy = data.aws_iam_policy_document.ec2_assume_role.json
max_session_duration = 3600 * 12
tags = {
"resinstack:cluster" = var.cluster_tag
}
}
resource "aws_iam_role_policy_attachment" "controller_kms" {
for_each = local.key_purposes
role = aws_iam_role.controller.name
policy_arn = aws_iam_policy.kms_policy[each.value].arn
}
resource "aws_iam_role_policy_attachment" "controller_keys" {
role = aws_iam_role.controller.name
policy_arn = aws_iam_policy.controller_keys.arn
}
resource "aws_iam_instance_profile" "controller" {
name = "resinstack-boundary-controller-${var.cluster_tag}"
role = aws_iam_role.controller.name
}
resource "aws_iam_role" "worker" {
name = "resinstack-boundary-worker-${var.cluster_tag}"
assume_role_policy = data.aws_iam_policy_document.ec2_assume_role.json
max_session_duration = 3600 * 12
tags = {
"resinstack:cluster" = var.cluster_tag
}
}
resource "aws_iam_role_policy_attachment" "worker_kms" {
role = aws_iam_role.worker.name
policy_arn = aws_iam_policy.kms_policy["worker-auth"].arn
}
resource "aws_iam_instance_profile" "worker" {
name = "resinstack-boundary-worker-${var.cluster_tag}"
role = aws_iam_role.worker.name
}