-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfirefox.tf
71 lines (62 loc) · 1.96 KB
/
firefox.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
resource "aws_ecs_task_definition" "firefox" {
family = "${var.id}-firefox"
container_definitions = jsonencode(local.firefox)
execution_role_arn = aws_iam_role.this.arn
requires_compatibilities = ["FARGATE"]
network_mode = "awsvpc"
cpu = var.node_cpu
memory = var.node_memory
tags = var.tags
}
resource "aws_ecs_service" "firefox" {
name = "firefox"
cluster = aws_ecs_cluster.this.id
task_definition = aws_ecs_task_definition.firefox.arn
desired_count = var.firefox_replicas
launch_type = "FARGATE"
propagate_tags = "SERVICE"
tags = var.tags
network_configuration {
security_groups = [aws_security_group.ecs.id]
subnets = tolist(var.subnet_ids)
}
}
locals {
firefox = [
{
name = "this"
image = var.firefox_image
essential = true
environment = concat(local.firefox_env, var.environment)
command = [
"/bin/bash",
"-c",
"export REMOTE_HOST=http://$(curl -s http://169.254.170.2/v2/metadata | jq -r '.Containers[1].Networks[0].IPv4Addresses[0]'):5555 ; /opt/bin/entry_point.sh"
]
portMappings = [
{
containerPort = 5555
},
]
logConfiguration = {
logDriver = "awslogs"
options = {
awslogs-group = aws_cloudwatch_log_group.firefox.name
awslogs-region = data.aws_region.this.name
awslogs-stream-prefix = "ecs"
}
}
}
]
firefox_env = [
{
name = "HUB_HOST"
value = aws_route53_record.this.name
},
]
}
resource "aws_cloudwatch_log_group" "firefox" {
name = "${var.id}-firefox"
retention_in_days = var.log_retention
tags = var.tags
}