-
Notifications
You must be signed in to change notification settings - Fork 1
/
fargate.tf
85 lines (64 loc) · 2.24 KB
/
fargate.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
79
80
81
82
83
84
85
module "ecs-fargate" {
source = "umotif-public/ecs-fargate/aws"
version = "~> 6.1.0"
name_prefix = "ecs-fargate-n8n"
vpc_id = module.vpc.vpc_id
private_subnet_ids = module.vpc.private_subnets
health_check_grace_period_seconds = 300
desired_count = 1
cluster_id = aws_ecs_cluster.ecs_cluster.id
#task_container_image = "${local.account_id}.dkr.ecr.${local.region}.amazonaws.com/${aws_ecr_repository.n8n_ecr.name}:latest"
task_container_image = "n8nio/n8n:latest"
task_definition_cpu = 1024
task_definition_memory = 4096
load_balanced = true
/* lifecycle {
ignore_changes = [
task_definition
]
} */
task_container_port = 5678
task_container_assign_public_ip = false
health_check = {
matcher = "200-401"
port = "traffic-port"
path = "/healthz"
}
target_groups = [
{
target_group_name = "ecs-fargate-n8n-tg"
container_port = 5678
}
]
task_container_environment = {
# aurora mysql env vars
DB_TYPE = "mysqldb"
DB_MYSQLDB_DATABASE = var.db_name
DB_MYSQLDB_HOST = module.aurora.cluster_endpoint
DB_MYSQLDB_PORT = module.aurora.cluster_port
DB_MYSQLDB_USER = "admin"
DB_MYSQLDB_PASSWORD = random_password.aurora_mysql_master_password.result
# elasticache redis env vars
QUEUE_BULL_PREFIX = "n8n"
QUEUE_BULL_REDIS_DB = "0"
QUEUE_BULL_REDIS_HOST = module.redis.elasticache_replication_group_primary_endpoint_address
QUEUE_BULL_REDIS_PORT = module.redis.elasticache_port
QUEUE_BULL_REDIS_TIMEOUT_THRESHOLD = "1000" #seconds
QUEUE_RECOVERY_INTERVAL = "60" #seconds
}
tags = merge(local.common_tags, {})
depends_on = [
module.alb,
module.aurora,
module.redis
]
}
resource "aws_security_group_rule" "sg_rule_ecs" {
security_group_id = module.ecs-fargate.service_sg_id
type = "ingress"
from_port = 5678
to_port = 5678
protocol = "tcp"
#cidr_blocks = [module.vpc.vpc_cidr_block]
source_security_group_id = module.alb_security_group.security_group_id
}