-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.tf
49 lines (41 loc) · 1.34 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
resource "aws_ecs_cluster" "mongo_ecs" {
name = var.name
tags = var.tags
}
resource "aws_ecs_task_definition" "mongo-task" {
container_definitions = data.template_file.container_definition.rendered
family = var.name
network_mode = "bridge"
requires_compatibilities = ["EC2"]
volume {
name = var.name
docker_volume_configuration {
scope = "shared"
autoprovision = true
driver = "rexray/ebs"
driver_opts = {
volumetype = var.ebs_volume_type
size = var.ebs_volume_size
}
}
}
tags = var.tags
}
resource "aws_ecs_service" "mongodb-ecs-service" {
name = var.name
cluster = aws_ecs_cluster.mongo_ecs.arn
task_definition = aws_ecs_task_definition.mongo-task.arn
desired_count = 1
deployment_minimum_healthy_percent = 0
deployment_maximum_percent = 100
launch_type = "EC2"
}
data "template_file" "container_definition" {
template = file("${path.module}/container-definitions/mongo.tpl")
vars = {
mongo_version = var.mongo_version
mongo_container_cpu = var.mongo_container_cpu
mongo_container_memory = var.mongo_container_memory
volume_name = var.name
}
}