diff --git a/.github/workflows/switch.yml b/.github/workflows/switch.yml index 37329c82e..4ea378f38 100644 --- a/.github/workflows/switch.yml +++ b/.github/workflows/switch.yml @@ -45,7 +45,7 @@ jobs: [ { "identifier": "switch-staging", - "branch": "develop", + "branch": "support_connect_verb", "image_tag": "staging", "ecs_service": "switch-staging", "ecs_cluster": "somleng-switch-staging" diff --git a/infrastructure/modules/somleng_switch/switch.tf b/infrastructure/modules/somleng_switch/switch.tf index 4f4178208..f2da41c6f 100644 --- a/infrastructure/modules/somleng_switch/switch.tf +++ b/infrastructure/modules/somleng_switch/switch.tf @@ -51,6 +51,11 @@ resource "aws_cloudwatch_log_group" "freeswitch_event_logger" { retention_in_days = 7 } +resource "aws_cloudwatch_log_group" "redis" { + name = "${var.switch_identifier}-redis" + retention_in_days = 7 +} + # Security Group resource "aws_security_group" "switch" { name = var.switch_identifier @@ -389,6 +394,7 @@ data "template_file" "switch" { freeswitch_logs_group = aws_cloudwatch_log_group.freeswitch.name freeswitch_event_logger_logs_group = aws_cloudwatch_log_group.freeswitch_event_logger.name app_logs_group = aws_cloudwatch_log_group.switch_app.name + redis_logs_group = aws_cloudwatch_log_group.redis.name logs_group_region = var.aws_region app_environment = var.app_environment diff --git a/infrastructure/modules/somleng_switch/templates/switch.json.tpl b/infrastructure/modules/somleng_switch/templates/switch.json.tpl index acee31436..bbd60fdb8 100644 --- a/infrastructure/modules/somleng_switch/templates/switch.json.tpl +++ b/infrastructure/modules/somleng_switch/templates/switch.json.tpl @@ -35,6 +35,12 @@ } }, "startTimeout": 120, + "dependsOn": [ + { + "containerName": "redis", + "condition": "HEALTHY" + } + ], "healthCheck": { "command": [ "CMD-SHELL", "wget --server-response --spider --quiet http://localhost:3000/health_checks 2>&1 | grep '200 OK' > /dev/null" ], "interval": 10, @@ -85,6 +91,10 @@ { "name": "SERVICES_FUNCTION_ARN", "value": "${services_function_arn}" + }, + { + "name": "REDIS_URL", + "value": "redis://localhost:6379/1" } ] }, @@ -216,6 +226,30 @@ } ] }, + { + "name": "redis", + "image": "public.ecr.aws/docker/library/redis:alpine", + "logConfiguration": { + "logDriver": "awslogs", + "options": { + "awslogs-group": "${redis_logs_group}", + "awslogs-region": "${logs_group_region}", + "awslogs-stream-prefix": "${app_environment}" + } + }, + "essential": true, + "healthCheck": { + "command": [ "CMD-SHELL", "redis-cli", "--raw", "incr", "ping" ], + "interval": 10, + "retries": 10, + "timeout": 5 + }, + "portMappings": [ + { + "containerPort": 6379 + } + ] + }, { "name": "freeswitch-event-logger", "image": "${freeswitch_event_logger_image}:latest", @@ -228,7 +262,7 @@ } }, "startTimeout": 120, - "essential": false, + "essential": true, "secrets": [ { "name": "EVENT_SOCKET_PASSWORD", @@ -239,12 +273,20 @@ { "containerName": "freeswitch", "condition": "HEALTHY" + }, + { + "containerName": "redis", + "condition": "HEALTHY" } ], "environment": [ { "name": "EVENT_SOCKET_HOST", "value": "localhost:${freeswitch_event_socket_port}" + }, + { + "name": "REDIS_URL", + "value": "redis://localhost:6379/1" } ] }