-
Notifications
You must be signed in to change notification settings - Fork 13
/
data.tf
113 lines (96 loc) · 2.11 KB
/
data.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
data "aws_region" "region" {
name = var.region
}
data "aws_vpc" "vpc" {
id = var.vpc_id
}
# ALB data sources
data "aws_acm_certificate" "alb" {
count = var.alb_enable_https ? 1 : 0
domain = var.acm_cert_domain
most_recent = true
statuses = ["ISSUED"]
}
data "aws_security_group" "ecs" {
id = var.ecs_security_group_id
vpc_id = data.aws_vpc.vpc.id
}
# IAM data sources
data "aws_iam_policy_document" "task_policy" {
statement {
actions = [
"ec2:Describe*",
"autoscaling:Describe*",
"ec2:DescribeAddresses",
"ec2:DescribeInstances",
"ec2:DescribeTags",
]
resources = ["*"]
}
statement {
actions = [
"cloudwatch:GetMetricStatistics",
"logs:DescribeLogStreams",
"logs:CreateLogStream",
"logs:GetLogEvents",
"logs:PutLogEvents",
]
resources = [
"*",
]
}
}
data "aws_iam_policy_document" "assume_role_task" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ecs-tasks.amazonaws.com"]
}
}
}
data "aws_iam_policy_document" "assume_role_service" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ecs.amazonaws.com"]
}
}
}
data "aws_iam_policy_document" "task_execution_role_policy" {
statement {
effect = "Allow"
actions = ["secretsmanager:GetSecretValue"]
resources = concat([var.docker_secret], var.secret_arns)
}
dynamic "statement" {
for_each = length(var.ssm_param_arns) > 0 ? [1] : []
content {
effect = "Allow"
actions = [
"ssm:GetParameter",
"ssm:GetParameters"
]
resources = var.ssm_param_arns
}
}
dynamic "statement" {
for_each = length(var.encryption_keys) > 0 ? [1] : []
content {
effect = "Allow"
actions = [
"kms:Decrypt"
]
resources = var.encryption_keys
}
}
statement {
effect = "Allow"
actions = [
"ecs:ExecuteCommand",
"ecs:DescribeTasks"
]
resources = [aws_ecs_task_definition.task.arn]
}
}