-
Notifications
You must be signed in to change notification settings - Fork 0
/
role.tf
49 lines (41 loc) · 1.16 KB
/
role.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
# creates an application role that the container/task runs as
resource "aws_iam_role" "app_role" {
name = "${var.app}-${var.environment}"
assume_role_policy = data.aws_iam_policy_document.app_role_assume_role_policy.json
}
# assigns the app policy
resource "aws_iam_role_policy" "app_policy" {
name = "${var.app}-${var.environment}"
role = aws_iam_role.app_role.id
policy = data.aws_iam_policy_document.app_policy.json
}
data "aws_iam_policy_document" "app_policy" {
statement {
actions = [
"ecs:DescribeClusters",
]
resources = [
local.ecs_cluster_arn,
]
}
}
data "aws_caller_identity" "current" {
}
# allow role to be assumed by ecs and local saml users (for development)
data "aws_iam_policy_document" "app_role_assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ecs-tasks.amazonaws.com"]
}
}
}
# The name of the role assumed by the task at runtime
output "ecs_role_name" {
value = aws_iam_role.app_role.name
}
# The arn of the role assumed by the task at runtime
output "ecs_role_arn" {
value = aws_iam_role.app_role.arn
}