-
Notifications
You must be signed in to change notification settings - Fork 1
/
cicd.tf
64 lines (56 loc) · 1.59 KB
/
cicd.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
resource "aws_iam_openid_connect_provider" "github_actions" {
url = "https://token.actions.githubusercontent.com"
client_id_list = ["sts.amazonaws.com"]
thumbprint_list = ["6938fd4d98bab03faadb97b34396831e3780aea1"]
tags = local.tags
}
module "gh_actions_role" {
source = "./modules/gh-actions-role"
repo = var.gh_repo_name
role_name = "gh-actions-${local.name_prefix}"
default_conditions = ["allow_master", "deny_pull_request"]
openid_connect_provider_arn = aws_iam_openid_connect_provider.github_actions.arn
policy_statement = {
ecs_task_def = {
effect = "Allow",
actions = [
"ecs:DescribeTaskDefinition",
"ecs:RegisterTaskDefinition",
],
resources = ["*"]
}
ecs_update_service = {
effect = "Allow",
actions = [
"ecs:UpdateService",
],
resources = [
aws_ecs_service.file_mgmt_app.id,
]
conditions = [
{
test = "ArnEquals"
variable = "ecs:cluster"
values = [aws_ecs_cluster.main.arn]
},
{
test = "ArnEquals"
variable = "ecs:task-definition"
values = [
aws_ecs_task_definition.file_mgmt_app.arn_without_revision,
"${aws_ecs_task_definition.file_mgmt_app.arn_without_revision}:*",
]
}
]
}
iam = {
effect = "Allow"
actions = ["iam:PassRole"]
resources = [
aws_iam_role.ecs_exec_role.arn,
aws_iam_role.file_mgmt_app_ecs_task_role.arn,
]
}
}
tags = local.tags
}