-
Notifications
You must be signed in to change notification settings - Fork 43
/
iam.tf
44 lines (36 loc) · 1.03 KB
/
iam.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
data "aws_iam_policy_document" "kong-ssm" {
statement {
actions = ["ssm:DescribeParameters"]
resources = ["*"]
}
statement {
actions = ["ssm:GetParameter"]
resources = ["arn:aws:ssm:*:*:parameter/${var.service}/${var.environment}/*"]
}
statement {
actions = ["kms:Decrypt"]
resources = [aws_kms_alias.kong.target_key_arn]
}
}
resource "aws_iam_role_policy" "kong-ssm" {
name = format("%s-%s-ssm", var.service, var.environment)
role = aws_iam_role.kong.id
policy = data.aws_iam_policy_document.kong-ssm.json
}
data "aws_iam_policy_document" "kong" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
}
}
resource "aws_iam_role" "kong" {
name = format("%s-%s", var.service, var.environment)
assume_role_policy = data.aws_iam_policy_document.kong.json
}
resource "aws_iam_instance_profile" "kong" {
name = format("%s-%s", var.service, var.environment)
role = aws_iam_role.kong.id
}