deploy-stack 0.12.3 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,62 @@
1
+ # --- Worker ECS Task Definition ---
2
+ resource "aws_ecs_task_definition" "worker" {
3
+ family = "{{PROJECT_NAME}}-worker-task"
4
+ network_mode = "awsvpc"
5
+ requires_compatibilities = ["FARGATE"]
6
+ cpu = "{{CPU}}"
7
+ memory = "{{MEMORY}}"
8
+ execution_role_arn = aws_iam_role.execution_role.arn
9
+ task_role_arn = aws_iam_role.task_role.arn
10
+
11
+ container_definitions = jsonencode([
12
+ {
13
+ name = "{{PROJECT_NAME}}-worker-container"
14
+ image = "${aws_ecr_repository.app.repository_url}:latest"
15
+ essential = true
16
+
17
+ environment = [
18
+ { "name": "NODE_ENV", "value": "production" },
19
+ {{DB_ENV_VARS}}
20
+ ]
21
+
22
+ secrets = concat(
23
+ [
24
+ for key in local.secret_keys : {
25
+ name = key
26
+ valueFrom = "${aws_secretsmanager_secret.app_secrets.arn}:${key}::"
27
+ }
28
+ ],
29
+ [
30
+ {{TASK_SECRETS}}
31
+ ]
32
+ )
33
+
34
+ {{WORKER_COMMAND}}
35
+
36
+ logConfiguration = {
37
+ logDriver = "awslogs"
38
+ options = {
39
+ "awslogs-group" = aws_cloudwatch_log_group.app_logs.name
40
+ "awslogs-region" = "{{REGION}}"
41
+ "awslogs-stream-prefix" = "worker" # Isolates worker logs from web logs
42
+ }
43
+ }
44
+ }
45
+ ])
46
+ }
47
+
48
+ # --- Worker ECS Service ---
49
+ # Notice there is NO load_balancer block. This service is strictly private.
50
+ resource "aws_ecs_service" "worker" {
51
+ name = "{{PROJECT_NAME}}-worker-service"
52
+ cluster = aws_ecs_cluster.main.id
53
+ task_definition = aws_ecs_task_definition.worker.arn
54
+ launch_type = "FARGATE"
55
+ desired_count = 1
56
+
57
+ network_configuration {
58
+ subnets = aws_subnet.public[*].id
59
+ security_groups = [aws_security_group.ecs_tasks.id]
60
+ assign_public_ip = true
61
+ }
62
+ }