forked from wardviaene/terraform-course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecs.tf
49 lines (48 loc) · 1.96 KB
/
ecs.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
data "aws_caller_identity" "current" {}
module "my-ecs" {
source = "github.com/in4it/terraform-modules//modules/ecs-cluster?ref=v1.0.0"
VPC_ID = "${module.vpc.vpc_id}"
CLUSTER_NAME = "my-ecs"
INSTANCE_TYPE = "t2.small"
SSH_KEY_NAME = "${aws_key_pair.mykeypair.key_name}"
VPC_SUBNETS = "${join(",", module.vpc.public_subnets)}"
ENABLE_SSH = true
SSH_SG = "${aws_security_group.allow-ssh.id}"
LOG_GROUP = "my-log-group"
AWS_ACCOUNT_ID = "${data.aws_caller_identity.current.account_id}"
AWS_REGION = "${var.AWS_REGION}"
}
module "my-service" {
source = "github.com/in4it/terraform-modules//modules/ecs-service?ref=v1.0.0"
VPC_ID = "${module.vpc.vpc_id}"
APPLICATION_NAME = "my-service"
APPLICATION_PORT = "80"
APPLICATION_VERSION = "latest"
CLUSTER_ARN = "${module.my-ecs.cluster_arn}"
SERVICE_ROLE_ARN = "${module.my-ecs.service_role_arn}"
AWS_REGION = "${var.AWS_REGION}"
HEALTHCHECK_MATCHER = "200"
CPU_RESERVATION = "256"
MEMORY_RESERVATION = "128"
LOG_GROUP = "my-log-group"
DESIRED_COUNT = 2
ALB_ARN = "${module.my-alb.alb_arn}"
}
module "my-alb" {
source = "github.com/in4it/terraform-modules//modules/alb?ref=v1.0.0"
VPC_ID = "${module.vpc.vpc_id}"
ALB_NAME = "my-alb"
VPC_SUBNETS = "${join(",", module.vpc.public_subnets)}"
DEFAULT_TARGET_ARN = "${module.my-service.target_group_arn}"
DOMAIN = "*.ecs.newtech.academy"
INTERNAL = false
ECS_SG = "${module.my-ecs.cluster_sg}"
}
module "my-alb-rule" {
source = "github.com/in4it/terraform-modules//modules/alb-rule?ref=v1.0.0"
LISTENER_ARN = "${module.my-alb.http_listener_arn}"
PRIORITY = 100
TARGET_GROUP_ARN = "${module.my-service.target_group_arn}"
CONDITION_FIELD = "host-header"
CONDITION_VALUES = ["subdomain.ecs.newtech.academy"]
}