-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodedeploy.tf
69 lines (55 loc) · 2.03 KB
/
codedeploy.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
resource "aws_codedeploy_app" "codedeploy" {
count = contains(var.pipeline_types,"build-unit-deploy") || contains(var.pipeline_types,"build-deploy") || contains(var.pipeline_types,"build-unit-migrate-deploy-update") ? 1 : 0
name = "${var.app_name}_${local.stack}_codedeploy_app"
compute_platform = "ECS"
}
resource "aws_codedeploy_deployment_group" "deployment_group" {
count = contains(var.pipeline_types,"build-unit-deploy") || contains(var.pipeline_types,"build-deploy") || contains(var.pipeline_types,"build-unit-migrate-deploy-update") ? 1 : 0
app_name = aws_codedeploy_app.codedeploy[0].name
deployment_group_name = "${var.app_name}_${local.stack}_deployment_group"
service_role_arn = "${aws_iam_role.codedeploy_iam_role.arn}"
deployment_config_name = "CodeDeployDefault.ECSAllAtOnce"
ecs_service {
cluster_name = "${var.ecs_cluster_name}"
service_name = "${local.stack}_${var.app_name}"
}
auto_rollback_configuration {
enabled = true
events = ["DEPLOYMENT_FAILURE"]
}
dynamic "blue_green_deployment_config" {
for_each = var.blue_target_group_arn == "" ? [] : [1]
content {
deployment_ready_option {
action_on_timeout = "CONTINUE_DEPLOYMENT"
}
terminate_blue_instances_on_deployment_success {
action = "TERMINATE"
termination_wait_time_in_minutes = 5
}
}
}
dynamic "deployment_style" {
for_each = var.blue_target_group_arn == "" ? [] : [1]
content {
deployment_option = "WITH_TRAFFIC_CONTROL"
deployment_type = "BLUE_GREEN"
}
}
dynamic "load_balancer_info" {
for_each = var.blue_target_group_arn == "" ? [] : [1]
content {
target_group_pair_info {
prod_traffic_route {
listener_arns = var.listener_arns
}
target_group {
name = "${var.blue_target_group_arn}"
}
target_group {
name = "${var.green_target_group_arn}"
}
}
}
}
}