-
-
Notifications
You must be signed in to change notification settings - Fork 153
/
Copy pathmain.tf
78 lines (71 loc) · 3.17 KB
/
main.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
module "default_label" {
source = "git::https://github.com/cloudposse/terraform-terraform-label.git?ref=tags/0.1.2"
name = "${var.name}"
namespace = "${var.namespace}"
stage = "${var.stage}"
}
module "ecr" {
source = "git::https://github.com/cloudposse/terraform-aws-ecr.git?ref=tags/0.2.5"
name = "${var.name}"
namespace = "${var.namespace}"
stage = "${var.stage}"
attributes = "${compact(concat(var.attributes, list("ecr")))}"
}
resource "aws_cloudwatch_log_group" "app" {
name = "${module.default_label.id}"
tags = "${module.default_label.tags}"
}
module "alb_ingress" {
source = "git::https://github.com/cloudposse/terraform-aws-alb-ingress.git?ref=tags/0.2.2"
name = "${var.name}"
namespace = "${var.namespace}"
stage = "${var.stage}"
attributes = "${compact(concat(var.attributes, list("alb", "ingress")))}"
vpc_id = "${var.vpc_id}"
listener_arns = ["${var.listener_arns}"]
listener_arns_count = "${var.listener_arns_count}"
health_check_path = "${var.alb_ingress_healthcheck_path}"
paths = ["${var.alb_ingress_paths}"]
hosts = ["${var.alb_ingress_hosts}"]
}
module "container_definition" {
source = "git::https://github.com/cloudposse/terraform-aws-ecs-container-definition.git?ref=tags/0.1.3"
container_name = "${module.default_label.id}"
container_image = "${var.container_image}"
container_memory = "${var.container_memory}"
container_port = "${var.container_port}"
log_options = {
"awslogs-region" = "${var.aws_logs_region}"
"awslogs-group" = "${aws_cloudwatch_log_group.app.name}"
"awslogs-stream-prefix" = "${var.name}"
}
}
module "ecs_alb_service_task" {
source = "git::https://github.com/cloudposse/terraform-aws-ecs-alb-service-task.git?ref=tags/0.2.0"
name = "${var.name}"
namespace = "${var.namespace}"
stage = "${var.stage}"
alb_target_group_arn = "${module.alb_ingress.target_group_arn}"
container_definition_json = "${module.container_definition.json}"
container_name = "${module.default_label.id}"
ecr_repository_name = "${module.ecr.repository_name}"
ecs_cluster_arn = "${var.ecs_cluster_arn}"
launch_type = "${var.launch_type}"
vpc_id = "${var.vpc_id}"
security_group_ids = ["${var.ecs_security_group_ids}"]
private_subnet_ids = ["${var.ecs_private_subnet_ids}"]
}
module "ecs_codepipeline" {
enabled = "${var.codepipeline_enabled}"
source = "git::https://github.com/cloudposse/terraform-aws-ecs-codepipeline.git?ref=tags/0.1.2"
name = "${var.name}"
namespace = "${var.namespace}"
stage = "${var.stage}"
github_oauth_token = "${var.github_oauth_token}"
repo_owner = "${var.repo_owner}"
repo_name = "${var.repo_name}"
branch = "${var.branch}"
service_name = "${module.ecs_alb_service_task.service_name}"
ecs_cluster_name = "${var.ecs_cluster_name}"
privileged_mode = "true"
}