Articles in this section
Category / Section

ECS Multi Container Deployment

Published:
Updated:

Amazon Elastic Container Service (ECS) supports multi-container deployments, allowing you to run multiple containers within a multiple task definition. This approach is beneficial for deploying complex applications that require multiple services to work together seamlessly.

Action 1 : Create a Fargate cluster in ECS to host the application within services.
Action 2 : Create task definitions for each deployment and services to deploy the respective task definitions.

Please follow the steps below to deploy the application in the ECS multi-container environment:

  • Create Multiple Task Definitions for each container.
  • The task definition is provided in JSON format; you can modify it as needed in Terraform.

IDP Web Task
{
  "family": "id-web-task",
  "containerDefinitions": [
      {
          "name": "id_web_container",
          "image": "us-docker.pkg.dev/boldreports/v6-2-32/bold-identity:6.2.32",
          "cpu": 1024,
          "portMappings": [
              {
                  "name": "id_web_container-80-tcp",
                  "containerPort": 80,
                  "hostPort": 80,
                  "protocol": "tcp"
              }
          ],
          "essential": true,
          "environment": [
              {
                  "name": "APP_BASE_URL",
                  "value": "<Load Balancer DNS with http porotocol>"
              }
          ],
          "mountPoints": [
              {
                  "sourceVolume": "boldreports-EFS",
                  "containerPath": "/application/app_data",
                  "readOnly": false
              }
          ],
          "volumesFrom": [],
          "logConfiguration": {
              "logDriver": "awslogs",
              "options": {
                  "awslogs-group": "/ecs/boldreports",
                  "awslogs-region": "us-east-1",
                  "awslogs-stream-prefix": "boldreports"
              },
              "secretOptions": []
          },
          "systemControls": []
      }
  ],
  “taskRoleArn”: “arn:aws:iam::142887710098:role/ECS39713role”, //Add your task role
  “executionRoleArn”: “arn:aws:iam::142887710098:role/ecsTaskExecutionRole”, //Add your execution task role
  "networkMode": "awsvpc",
  "volumes": [
      {
          "name": "boldreports-EFS",
          "efsVolumeConfiguration": {
              "fileSystemId": "<file_system_id>",
              "rootDirectory": "/"
          }
      }
  ],
  "requiresCompatibilities": [
      "FARGATE"
  ],
  "cpu": "4096",
  "memory": "8192"
}
IDP API Task
{
  "family": "id-api-task",
  "containerDefinitions": [
      {
          "name": "id_api_container",
          "image": "us-docker.pkg.dev/boldreports/v6-2-32/bold-idp-api:6.2.32",
          "cpu": 1024,
          "portMappings": [
              {
                  "name": "id_api_container-80-tcp",
                  "containerPort": 80,
                  "hostPort": 80,
                  "protocol": "tcp"
              }
          ],
          "essential": true,
          "environment": [],
          "mountPoints": [
              {
                  "sourceVolume": "boldreports-EFS",
                  "containerPath": "/application/app_data",
                  "readOnly": false
              }
          ],
          "volumesFrom": [],
          "logConfiguration": {
              "logDriver": "awslogs",
              "options": {
                  "awslogs-group": "/ecs/boldreports",
                  "awslogs-region": "us-east-1",
                  "awslogs-stream-prefix": "boldreports"
              },
              "secretOptions": []
          },
          "systemControls": []
      }
  ],
  “taskRoleArn”: “arn:aws:iam::142887710098:role/ECS39713role”, //Add your task role
  “executionRoleArn”: “arn:aws:iam::142887710098:role/ecsTaskExecutionRole”, //Add your execution task role
  "networkMode": "awsvpc",
  "volumes": [
      {
          "name": "boldreports-EFS",
          "efsVolumeConfiguration": {
              "fileSystemId": "<file_system_id>",
              "rootDirectory": "/"
          }
      }
  ],
  "requiresCompatibilities": [
      "FARGATE"
  ],
  "cpu": "4096",
  "memory": "8192"
}
IDP UMS Task
{
  "family": "id-ums-task",
  "containerDefinitions": [
      {
          "name": "id_ums_container",
          "image": "us-docker.pkg.dev/boldreports/v6-2-32/bold-ums:6.2.32",
          "cpu": 1024,
          "portMappings": [
              {
                  "name": "cont3",
                  "containerPort": 80,
                  "hostPort": 80,
                  "protocol": "tcp",
                  "appProtocol": "http"
              }
          ],
          "essential": true,
          "environment": [],
          "mountPoints": [
              {
                  "sourceVolume": "boldreports-EFS",
                  "containerPath": "/application/app_data",
                  "readOnly": false
              }
          ],
          "volumesFrom": [],
          "logConfiguration": {
              "logDriver": "awslogs",
              "options": {
                  "awslogs-group": "/ecs/boldreports",
                  "awslogs-region": "us-east-1",
                  "awslogs-stream-prefix": "boldreports"
              },
              "secretOptions": []
          },
          "systemControls": []
      }
  ],
  “taskRoleArn”: “arn:aws:iam::142887710098:role/ECS39713role”, //Add your task role
  “executionRoleArn”: “arn:aws:iam::142887710098:role/ecsTaskExecutionRole”, //Add your execution task role
  "networkMode": "awsvpc",
  "volumes": [
      {
          "name": "boldreports-EFS",
          "efsVolumeConfiguration": {
              "fileSystemId": "<file_system_id>",
              "rootDirectory": "/"
          }
      }
  ],
  "requiresCompatibilities": [
      "FARGATE"
  ],
  "cpu": "4096",
  "memory": "8192"
}
Reporting Web
{
  "family": "reports-web-task",
  "containerDefinitions": [
      {
          "name": "reports_web_container",
          "image": "us-docker.pkg.dev/boldreports/v6-2-32/boldreports-server:6.2.32",
          "cpu": 1024,
          "portMappings": [
              {
                  "name": "cont4",
                  "containerPort": 80,
                  "hostPort": 80,
                  "protocol": "tcp",
                  "appProtocol": "http"
              }
          ],
          "essential": true,
          "environment": [],
          "mountPoints": [
              {
                  "sourceVolume": "boldreports-EFS",
                  "containerPath": "/application/app_data",
                  "readOnly": false
              }
          ],
          "volumesFrom": [],
          "logConfiguration": {
              "logDriver": "awslogs",
              "options": {
                  "awslogs-group": "/ecs/boldreports",
                  "awslogs-region": "us-east-1",
                  "awslogs-stream-prefix": "boldreports6"
              },
              "secretOptions": []
          },
          "systemControls": []
      }
  ],
  “taskRoleArn”: “arn:aws:iam::142887710098:role/ECS39713role”, //Add your task role
  “executionRoleArn”: “arn:aws:iam::142887710098:role/ecsTaskExecutionRole”, //Add your execution task role
  "networkMode": "awsvpc",
  "volumes": [
      {
          "name": "boldreports-EFS",
          "efsVolumeConfiguration": {
              "fileSystemId": "<file_system_id>",
              "rootDirectory": "/"
          }
      }
  ],
  "requiresCompatibilities": [
      "FARGATE"
  ],
  "cpu": "4096",
  "memory": "8192"
}
Reporting API Task
{
  "family": "reports-api-task",
  "containerDefinitions": [
      {
          "name": "reports_api_container",
          "image": "us-docker.pkg.dev/boldreports/v6-2-32/boldreports-server-api:6.2.32",
          "cpu": 1024,
          "portMappings": [
              {
                  "name": "cont5",
                  "containerPort": 80,
                  "hostPort": 80,
                  "protocol": "tcp",
                  "appProtocol": "http"
              }
          ],
          "essential": true,
          "environment": [],
          "mountPoints": [
              {
                  "sourceVolume": "boldreports-EFS",
                  "containerPath": "/application/app_data",
                  "readOnly": false
              }
          ],
          "volumesFrom": [],
          "logConfiguration": {
              "logDriver": "awslogs",
              "options": {
                  "awslogs-group": "/ecs/boldreports",
                  "awslogs-region": "us-east-1",
                  "awslogs-stream-prefix": "boldreports5"
              },
              "secretOptions": []
          },
          "systemControls": []
      }
  ],
  “taskRoleArn”: “arn:aws:iam::142887710098:role/ECS39713role”, //Add your task role
  “executionRoleArn”: “arn:aws:iam::142887710098:role/ecsTaskExecutionRole”, //Add your execution task role
  "networkMode": "awsvpc",
  "volumes": [
      {
          "name": "boldreports-EFS",
          "efsVolumeConfiguration": {
              "fileSystemId": "<file_system_id>",
              "rootDirectory": "/"
          }
      }
  ],
  "requiresCompatibilities": [
      "FARGATE"
  ],
  "cpu": "4096",
  "memory": "8192"
}
Reporting Jobs Task
{
  "family": "reports-jobs-task",
  "containerDefinitions": [
      {
          "name": "reports_jobs_container",
          "image": "us-docker.pkg.dev/boldreports/v6-2-32/boldreports-server-jobs:6.2.32",
          "cpu": 1024,
          "portMappings": [
              {
                  "name": "cont6",
                  "containerPort": 80,
                  "hostPort": 80,
                  "protocol": "tcp",
                  "appProtocol": "http"
              }
          ],
          "essential": true,
          "environment": [],
          "mountPoints": [
              {
                  "sourceVolume": "boldreports-EFS",
                  "containerPath": "/application/app_data",
                  "readOnly": false
              }
          ],
          "volumesFrom": [],
          "logConfiguration": {
              "logDriver": "awslogs",
              "options": {
                  "awslogs-group": "/ecs/boldreports",
                  "awslogs-region": "us-east-1",
                  "awslogs-stream-prefix": "boldreports4"
              },
              "secretOptions": []
          },
          "systemControls": []
      }
  ],
  “taskRoleArn”: “arn:aws:iam::142887710098:role/ECS39713role”, //Add your task role
  “executionRoleArn”: “arn:aws:iam::142887710098:role/ecsTaskExecutionRole”, //Add your execution task role
  "networkMode": "awsvpc",
  "volumes": [
      {
          "name": "boldreports-EFS",
          "efsVolumeConfiguration": {
              "fileSystemId": "<file_system_id>",
              "rootDirectory": "/"
          }
      }
  ],
  "requiresCompatibilities": [
      "FARGATE"
  ],
  "cpu": "4096",
  "memory": "8192"
}
Reporting Reportservice Task
{
  "family": "reports-reportservice-task",
  "containerDefinitions": [
      {
          "name": "reports_reportservice_container",
          "image": "us-docker.pkg.dev/boldreports/v6-2-32/boldreports-designer:6.2.32",
          "cpu": 1024,
          "portMappings": [
              {
                  "name": "cont7",
                  "containerPort": 80,
                  "hostPort": 80,
                  "protocol": "tcp",
                  "appProtocol": "http"
              }
          ],
          "essential": true,
          "environment": [],
          "mountPoints": [
              {
                  "sourceVolume": "boldreports-EFS",
                  "containerPath": "/application/app_data",
                  "readOnly": false
              }
          ],
          "volumesFrom": [],
          "logConfiguration": {
              "logDriver": "awslogs",
              "options": {
                  "awslogs-group": "/ecs/boldreports",
                  "awslogs-region": "us-east-1",
                  "awslogs-stream-prefix": "boldreports3"
              },
              "secretOptions": []
          },
          "systemControls": []
      }
  ],
  “taskRoleArn”: “arn:aws:iam::142887710098:role/ECS39713role”, //Add your task role
  “executionRoleArn”: “arn:aws:iam::142887710098:role/ecsTaskExecutionRole”, //Add your execution task role
  "networkMode": "awsvpc",
  "volumes": [
      {
          "name": "boldreports-EFS",
          "efsVolumeConfiguration": {
              "fileSystemId": "<file_system_id>",
              "rootDirectory": "/"
          }
      }
  ],
  "requiresCompatibilities": [
      "FARGATE"
  ],
  "cpu": "4096",
  "memory": "8192"
}
Reporting Viewer
{
  "family": "reports-viewer-task",
  "containerDefinitions": [
      {
          "name": "reports_viewer_container",
          "image": "us-docker.pkg.dev/boldreports/v6-2-32/boldreports-viewer:6.2.32",
          "cpu": 1024,
          "portMappings": [
              {
                  "name": "cont8",
                  "containerPort": 80,
                  "hostPort": 80,
                  "protocol": "tcp",
                  "appProtocol": "http"
              }
          ],
          "essential": true,
          "environment": [],
          "mountPoints": [
              {
                  "sourceVolume": "boldreports-EFS",
                  "containerPath": "/application/app_data",
                  "readOnly": false
              }
          ],
          "volumesFrom": [],
          "logConfiguration": {
              "logDriver": "awslogs",
              "options": {
                  "awslogs-group": "/ecs/boldreports",
                  "awslogs-region": "us-east-1",
                  "awslogs-stream-prefix": "boldreports2"
              },
              "secretOptions": []
          },
          "systemControls": []
      }
  ],
  "taskRoleArn": "arn:aws:iam::142887710098:role/ECS39713role", //Add you task role
  "executionRoleArn": "arn:aws:iam::142887710098:role/ecsTaskExecutionRole", //Add your execution role.
  "networkMode": "awsvpc",
  "volumes": [
      {
          "name": "boldreports-EFS",
          "efsVolumeConfiguration": {
              "fileSystemId": "<file_system_id>",
              "rootDirectory": "/"
          }
      }
  ],
  "requiresCompatibilities": [
      "FARGATE"
  ],
  "cpu": "4096",
  "memory": "8192"
}
Reporting ETL
{
  "family": "reports-etl-task",
  "containerDefinitions": [
      {
          "name": "reports_etl_container",
          "image": "us-docker.pkg.dev/boldreports-dev/images/bold-etl:6.2.33_alb_etl",
          "cpu": 1024,
          "portMappings": [
              {
                  "name": "cont9",
                  "containerPort": 80,
                  "hostPort": 80,
                  "protocol": "tcp",
                  "appProtocol": "http"
              }
          ],
          "essential": true,
          "environment": [],
          "mountPoints": [
              {
                  "sourceVolume": "boldreports-EFS",
                  "containerPath": "/application/app_data",
                  "readOnly": false
              }
          ],
          "volumesFrom": [],
          "logConfiguration": {
              "logDriver": "awslogs",
              "options": {
                  "awslogs-group": "/ecs/boldreports",
                  "awslogs-region": "us-east-1",
                  "awslogs-stream-prefix": "boldreports1"
              },
              "secretOptions": []
          },
          "systemControls": []
      }
  ],
  “taskRoleArn”: “arn:aws:iam::142887710098:role/ECS39713role”, //Add your task role
  “executionRoleArn”: “arn:aws:iam::142887710098:role/ecsTaskExecutionRole”, //Add your execution task role
  "networkMode": "awsvpc",
  "volumes": [
      {
          "name": "boldreports-EFS",
          "efsVolumeConfiguration": {
              "fileSystemId": "<file_system_id>",
              "rootDirectory": "/"
          }
      }
  ],
  "requiresCompatibilities": [
      "FARGATE"
  ],
  "cpu": "4096",
  "memory": "8192"
}
Service Creation

To create a service, please follow the steps below for all task definitions.

  • To create a service, select the task definition to deploy and provide a name for the service.

    deployment-configuration.png

  • Provide the VPC, subnets, and security group to be attached to the service.

    networking.png

  • To connect all the services, create a common load balancer and choose a listener based on your preference (port 80 or 443).

    load-balancing.png

  • Create a new target group for each service with the corresponding protocol. Provide the path pattern and evaluation order for each service as shown below.

    Services Path Pattern Evaluation Order
    id-web /* 10
    id-ums /ums/* 9
    id-api /api/* 8
    reporting-web /reporting/* 7
    reporting-jobs /reporting/jobs/* 6
    reporting-api /reporting/api/* 5
    reporting-viewer /reporting/viewer/* 4
    etl-service /etlservice/* 3
    reporting-designer /reporting/reportservice/* 2

    Note: For all services, the health check path should be /health-check, but for the ETL service, it should be /etlservice/health-check.

    target-group.png

  • Repeat the steps for each deployment and create the service.

    listner-rules.png

    reports-services.png

  • Once the targets in the target group reach a healthy state, use the load balancer’s DNS to access the file.

    load-balancer.png

Note:

  • Please verify the URL in the product.json file and update it as needed. Then, delete all files in the /mount_point/configuration directory except for product.json.
  • Documentation for port 80 has been provided; you should modify the listener based on your choice.
  • Now access the URL and configure the application by following the documentation below :
    Application Startup
Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied