ECS Multi-Container Deployment - EC2 Launch Type
This guide provides instructions for deploying a multi-container application on ECS using EC2 instances. It covers creating task definitions, setting up services, and configuring a load balancer for communication between containers. The deployment ensures proper routing and health checks for each service.
Step 1: Prerequisites for ECS Multi-Container Deployment
- Please complete the prerequisites for deploying a multi-container application using Amazon ECS with the EC2 launch type.
- Once the prerequisites are completed, the cluster will be created, and the cluster home page will display a view similar to the image below.
Step 2: Create Task Definitions
Create task definitions for each deployment and configure the services to deploy the respective task definitions.
-
To create a task definition, click the Create new task definition with JSON option, copy the task definition provided below for each service, paste it in the task definition creation window, and click Create.
- Create multiple task definitions for each container .
- The task definition is provided in JSON format.
IDP Web Task definition
{
"family": "id-web-task",
"containerDefinitions": [
{
"name": "id_web_container",
"image": "us-docker.pkg.dev/boldreports/v6-3-24/bold-identity:6.3.24",
"cpu": 256,
"portMappings": [
{
"name": "id_web_container-80-tcp",
"containerPort": 80,
"hostPort": 0,
"protocol": "tcp"
}
],
"essential": true,
"environment": [
{
"name": "APP_BASE_URL",
"value": "<app_base_url>"
},
{
"name": "INSTALL_OPTIONAL_LIBS", //Set this environment variable if optional libraries need to be installed.
"value": "mysql,oracle,postgresql,snowflake,googlebigquery"
}
],
"mountPoints": [
{
"sourceVolume": "boldreports-EFS",
"containerPath": "/application/app_data",
"readOnly": false
}
],
"volumesFrom": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/logs",
"mode": "non-blocking",
"awslogs-create-group": "true",
"max-buffer-size": "25m",
"awslogs-region": "us-east-2", //Specify your region for the logs group
"awslogs-stream-prefix": "bold"
}
},
"systemControls": []
}
],
"taskRoleArn": "arn:aws:iam::142887710098:role/ECS-taskrole", //Add your task role
"executionRoleArn": "arn:aws:iam::142887710098:role/ecsTaskExecutionRole", //Add your execution role
"networkMode": "bridge",
"volumes": [
{
"name": "boldreports-EFS",
"efsVolumeConfiguration": {
"fileSystemId": "<file-system-id>",
"rootDirectory": "/"
}
}
],
"placementConstraints": [],
"requiresCompatibilities": [
"EC2"
],
"cpu": "512",
"memory": "750",
"enableFaultInjection": false
}
IDP UMS Task defintion
{
"family": "id-ums-task",
"containerDefinitions": [
{
"name": "id_ums_container",
"image": "us-docker.pkg.dev/boldreports/v6-3-24/bold-ums:6.3.24",
"cpu": 256,
"portMappings": [
{
"name": "cont3",
"containerPort": 80,
"hostPort": 0,
"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/logs",
"mode": "non-blocking",
"awslogs-create-group": "true",
"max-buffer-size": "25m",
"awslogs-region": "us-east-2", //Specify your region for the logs group
"awslogs-stream-prefix": "bold"
}
},
"systemControls": []
}
],
"taskRoleArn": "arn:aws:iam::142887710098:role/ECS-taskrole", //Add your task role
"executionRoleArn": "arn:aws:iam::142887710098:role/ECS-task-define-role", //Add your execution role
"networkMode": "bridge",
"volumes": [
{
"name": "boldreports-EFS",
"efsVolumeConfiguration": {
"fileSystemId": "<file-system-id>",
"rootDirectory": "/"
}
}
],
"placementConstraints": [],
"requiresCompatibilities": [
"EC2"
],
"cpu": "512",
"memory": "750",
"enableFaultInjection": false
}
IDP API Task definition
{
"family": "id-api-task",
"containerDefinitions": [
{
"name": "id_api_container",
"image": "us-docker.pkg.dev/boldreports/v6-3-24/bold-idp-api:6.3.24",
"cpu": 256,
"portMappings": [
{
"name": "id_api_container-80-tcp",
"containerPort": 80,
"hostPort": 0,
"protocol": "tcp"
}
],
"essential": true,
"environment": [],
"mountPoints": [
{
"sourceVolume": "boldreports-EFS",
"containerPath": "/application/app_data",
"readOnly": false
}
],
"volumesFrom": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/logs",
"mode": "non-blocking",
"awslogs-create-group": "true",
"max-buffer-size": "25m",
"awslogs-region": "us-east-2", //Specify your region for the logs group
"awslogs-stream-prefix": "bold"
}
},
"systemControls": []
}
],
"taskRoleArn": "arn:aws:iam::142887710098:role/ECS-taskrole", //Add your task role
"executionRoleArn": "arn:aws:iam::142887710098:role/ECS-task-define-role", //Add your execution role
"networkMode": "bridge",
"volumes": [
{
"name": "boldreports-EFS",
"efsVolumeConfiguration": {
"fileSystemId": "<file-system-id>",
"rootDirectory": "/"
}
}
],
"placementConstraints": [],
"requiresCompatibilities": [
"EC2"
],
"cpu": "512",
"memory": "750",
"enableFaultInjection": false
}
Reporting Web definition
{
"family": "reports-web-task",
"containerDefinitions": [
{
"name": "reports_web_container",
"image": "us-docker.pkg.dev/boldreports/v6-3-24/boldreports-server:6.3.24",
"cpu": 256,
"portMappings": [
{
"name": "cont4",
"containerPort": 80,
"hostPort": 0,
"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/logs",
"mode": "non-blocking",
"awslogs-create-group": "true",
"max-buffer-size": "25m",
"awslogs-region": "us-east-2", //Specify your region for the logs group
"awslogs-stream-prefix": "bold"
}
},
"systemControls": []
}
],
"taskRoleArn": "arn:aws:iam::142887710098:role/ECS-taskrole", //Add your task role
"executionRoleArn": "arn:aws:iam::142887710098:role/ECS-task-define-role", //Add your execution role
"networkMode": "bridge",
"volumes": [
{
"name": "boldreports-EFS",
"efsVolumeConfiguration": {
"fileSystemId": "<file-system-id>",
"rootDirectory": "/"
}
}
],
"placementConstraints": [],
"requiresCompatibilities": [
"EC2"
],
"cpu": "512",
"memory": "750",
"enableFaultInjection": false
}
Reporting Jobs Task definition
{
"family": "reports-jobs-task",
"containerDefinitions": [
{
"name": "reports_jobs_container",
"image": "us-docker.pkg.dev/boldreports/v6-3-24/boldreports-server-jobs:6.3.24",
"cpu": 256,
"portMappings": [
{
"name": "cont6",
"containerPort": 80,
"hostPort": 0,
"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/logs",
"mode": "non-blocking",
"awslogs-create-group": "true",
"max-buffer-size": "25m",
"awslogs-region": "us-east-2", //Specify your region for the logs group
"awslogs-stream-prefix": "bold"
}
},
"systemControls": []
}
],
"taskRoleArn": "arn:aws:iam::142887710098:role/ECS-taskrole", //Add your task role
"executionRoleArn": "arn:aws:iam::142887710098:role/ECS-task-define-role", //Add your execution role
"networkMode": "bridge",
"volumes": [
{
"name": "boldreports-EFS",
"efsVolumeConfiguration": {
"fileSystemId": "<file-system-id>",
"rootDirectory": "/"
}
}
],
"placementConstraints": [],
"requiresCompatibilities": [
"EC2"
],
"cpu": "512",
"memory": "750",
"enableFaultInjection": false
}
Reporting API Task definition
{
"family": "reports-api-task",
"containerDefinitions": [
{
"name": "reports_api_container",
"image": "us-docker.pkg.dev/boldreports/v6-3-24/boldreports-server-api:6.3.24",
"cpu": 256,
"portMappings": [
{
"name": "cont5",
"containerPort": 80,
"hostPort": 0,
"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/logs",
"mode": "non-blocking",
"awslogs-create-group": "true",
"max-buffer-size": "25m",
"awslogs-region": "us-east-2", //Specify your region for the logs group
"awslogs-stream-prefix": "bold"
}
},
"systemControls": []
}
],
"taskRoleArn": "arn:aws:iam::142887710098:role/ECS-taskrole", //Add your task role
"executionRoleArn": "arn:aws:iam::142887710098:role/ECS-task-define-role", //Add your execution role
"networkMode": "bridge",
"volumes": [
{
"name": "boldreports-EFS",
"efsVolumeConfiguration": {
"fileSystemId": "<file-system-id>",
"rootDirectory": "/"
}
}
],
"placementConstraints": [],
"requiresCompatibilities": [
"EC2"
],
"cpu": "512",
"memory": "750",
"enableFaultInjection": false
}
Reporting Viewer definition
{
"family": "reports-viewer-task",
"containerDefinitions": [
{
"name": "reports_viewer_container",
"image": "us-docker.pkg.dev/boldreports/v6-3-24/boldreports-viewer:6.3.24",
"cpu": 256,
"portMappings": [
{
"name": "cont8",
"containerPort": 80,
"hostPort": 0,
"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/logs",
"mode": "non-blocking",
"awslogs-create-group": "true",
"max-buffer-size": "25m",
"awslogs-region": "us-east-2", //Specify your region for the logs group
"awslogs-stream-prefix": "bold"
}
},
"systemControls": []
}
],
"taskRoleArn": "arn:aws:iam::142887710098:role/ECS-taskrole", //Add your task role
"executionRoleArn": "arn:aws:iam::142887710098:role/ECS-task-define-role", //Add your execution role
"networkMode": "bridge",
"volumes": [
{
"name": "boldreports-EFS",
"efsVolumeConfiguration": {
"fileSystemId": "<file-system-id>",
"rootDirectory": "/"
}
}
],
"placementConstraints": [],
"requiresCompatibilities": [
"EC2"
],
"cpu": "512",
"memory": "750",
"enableFaultInjection": false
}
Reporting ETL definition
{
"family": "reports-etl-task",
"containerDefinitions": [
{
"name": "reports_etl_container",
"image": "us-docker.pkg.dev/boldreports-dev/images/bold-etl:6.3.24_alb_etl",
"cpu": 256,
"portMappings": [
{
"name": "cont9",
"containerPort": 80,
"hostPort": 0,
"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/logs",
"mode": "non-blocking",
"awslogs-create-group": "true",
"max-buffer-size": "25m",
"awslogs-region": "us-east-2", //Specify your region for the logs group
"awslogs-stream-prefix": "bold"
}
},
"systemControls": []
}
],
"taskRoleArn": "arn:aws:iam::142887710098:role/ECS-taskrole", //Add your task role
"executionRoleArn": "arn:aws:iam::142887710098:role/ECS-task-define-role", //Add your execution role
"networkMode": "bridge",
"volumes": [
{
"name": "boldreports-EFS",
"efsVolumeConfiguration": {
"fileSystemId": "<file-system-id>",
"rootDirectory": "/"
}
}
],
"placementConstraints": [],
"requiresCompatibilities": [
"EC2"
],
"cpu": "512",
"memory": "750",
"enableFaultInjection": false
}
Reporting Reportservice Task definition
{
"family": "reports-reportservice-task",
"containerDefinitions": [
{
"name": "reports_reportservice_container",
"image": "us-docker.pkg.dev/boldreports/v6-3-24/boldreports-designer:6.3.24",
"cpu": 256,
"portMappings": [
{
"name": "cont7",
"containerPort": 80,
"hostPort": 0,
"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/logs",
"mode": "non-blocking",
"awslogs-create-group": "true",
"max-buffer-size": "25m",
"awslogs-region": "us-east-2", //Specify your region for the logs group
"awslogs-stream-prefix": "bold"
}
},
"systemControls": []
}
],
"taskRoleArn": "arn:aws:iam::142887710098:role/ECS-taskrole", //Add your task role
"executionRoleArn": "arn:aws:iam::142887710098:role/ECS-task-define-role", //Add your execution role
"networkMode": "bridge",
"volumes": [
{
"name": "boldreports-EFS",
"efsVolumeConfiguration": {
"fileSystemId": "<file-system-id>",
"rootDirectory": "/"
}
}
],
"placementConstraints": [],
"requiresCompatibilities": [
"EC2"
],
"cpu": "512",
"memory": "750",
"enableFaultInjection": false
}
Please ensure that the EC2 instance’s security group is allowed within the ALB’s security group.
Step 3: Service Creation
To create a service, please follow the steps below for all task definitions.
-
Go to the created cluster and click Create under the Service tab.
-
Select EC2 as the launch type.
-
Select the task definition to be deployed and provide a name for the service.
-
To connect all the services, create a common load balancer and choose a listener based on your preference (80 or 443).
-
Create a new target group for each service with the respective 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.
-
Click Create to create the service.
-
Repeat the steps for each deployment and create the service.
-
Once the targets in the target group reach a healthy state, use the load balancer’s DNS to access the file.
Note:
- 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; if the load balancer is configured to listen on port 443, please ensure that all incoming requests on port 80 are automatically redirected to port 443.
- Now access the URL and configure the application by following the documentation below :
Application Startup
Please refer to the file below for the latest image: