Deploy Bold Reports on AWS ECS EC2 single container Using AWS CloudFormation
This article explains how to deploy Bold Reports on an existing Amazon ECS EC2 Cluster using AWS CloudFormation.
The CloudFormation templates automate the creation of the following AWS resources:
- Application Load Balancer (ALB)
- Target Group
- HTTPS Listener
- ECS Task Definition
- ECS Service
Prerequisites
Before deploying the CloudFormation templates, ensure the following AWS resources already exist.
| Resource | Description |
|---|---|
| VPC | Existing VPC where the application will be deployed |
| ECS Cluster | Existing ECS EC2 Cluster |
| EFS | Existing Amazon Elastic File System |
| Security Group | Security Group for the Load Balancer |
| Public Subnets | Minimum two public subnets |
| ACM Certificate | SSL certificate for HTTPS |
| IAM Roles | ECS Task Role and Execution Role |
Project Structure
BoldReports-CloudFormation
│
├── load-balancer.yaml
├── task-definition.yaml
└── ecs-service.yaml
Step 1 – Create the Application Load Balancer
The load-balancer.yaml template creates:
- Application Load Balancer
- Target Group
- HTTPS Listener
Create a file named load-balancer.yaml and copy the following content.
AWSTemplateFormatVersion: '2010-09-09'
Description: Create an Application Load Balancer, Target Group and HTTPS Listener for Bold Reports
Parameters:
LoadBalancerName:
Type: String
Default: boldreports-alb
Description: Name of the Application Load Balancer
TargetGroupName:
Type: String
Default: boldreports-tg
Description: Name of the Target Group
VpcId:
Type: AWS::EC2::VPC::Id
Description: Existing VPC ID
SecurityGroupId:
Type: AWS::EC2::SecurityGroup::Id
Description: Existing Security Group ID
PublicSubnet1:
Type: AWS::EC2::Subnet::Id
Description: First Public Subnet
PublicSubnet2:
Type: AWS::EC2::Subnet::Id
Description: Second Public Subnet
PublicSubnet3:
Type: AWS::EC2::Subnet::Id
Description: Third Public Subnet
CertificateArn:
Type: String
Description: ACM Certificate ARN for HTTPS Listener
Resources:
BoldReportsALB:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: !Ref LoadBalancerName
Scheme: internet-facing
Type: application
IpAddressType: ipv4
SecurityGroups:
- !Ref SecurityGroupId
Subnets:
- !Ref PublicSubnet1
- !Ref PublicSubnet2
- !Ref PublicSubnet3
Tags:
- Key: Application
Value: BoldReports
BoldReportsTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Name: !Ref TargetGroupName
VpcId: !Ref VpcId
Protocol: HTTP
Port: 80
TargetType: instance
HealthCheckEnabled: true
HealthCheckProtocol: HTTP
HealthCheckPort: traffic-port
HealthCheckPath: /
HealthCheckIntervalSeconds: 30
HealthCheckTimeoutSeconds: 5
HealthyThresholdCount: 2
UnhealthyThresholdCount: 3
Matcher:
HttpCode: "200-399"
Tags:
- Key: Application
Value: BoldReports
HTTPSListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
LoadBalancerArn: !Ref BoldReportsALB
Port: 443
Protocol: HTTPS
Certificates:
- CertificateArn: !Ref CertificateArn
SslPolicy: ELBSecurityPolicy-TLS13-1-2-2021-06
DefaultActions:
- Type: forward
TargetGroupArn: !Ref BoldReportsTargetGroup
Outputs:
LoadBalancerArn:
Description: Application Load Balancer ARN
Value: !Ref BoldReportsALB
LoadBalancerDNS:
Description: Application Load Balancer DNS Name
Value: !GetAtt BoldReportsALB.DNSName
TargetGroupArn:
Description: Target Group ARN
Value: !Ref BoldReportsTargetGroup
Export:
Name: BoldReportsTargetGroupArn
Deploy the Load Balancer Stack
Run the following command from the directory where load-balancer.yaml is saved.
aws cloudformation deploy `
--template-file load-balancer.yaml `
--stack-name boldreports-alb `
--parameter-overrides `
LoadBalancerName=boldreports-alb `
TargetGroupName=boldreports-tg `
VpcId=<vpc-id> `
SecurityGroupId=<security-group-id> `
PublicSubnet1=<subnet-1> `
PublicSubnet2=<subnet-2> `
PublicSubnet3=<subnet-3> `
CertificateArn=<ssl-certificate-acm-arn>
Verify the Deployment
After the deployment completes successfully:
Open the CloudFormation console.
- Verify the stack boldreports-alb is in the CREATE_COMPLETE state.
- Navigate to EC2 → Load Balancers and verify that boldreports-alb has been created.
- Navigate to EC2 → Target Groups and verify that boldreports-tg has been created.
- Open EC2 → Load Balancers → boldreports-alb → Listeners and verify that an HTTPS (443) listener is present and forwards requests to the boldreports-tg target group.
Step 2 – Create the ECS Task Definition
The task-definition.yaml template creates an ECS Task Definition for the Bold Reports application. It defines the container image, CPU and memory allocation, environment variables, CloudWatch logging configuration, and mounts the existing Amazon EFS file system for persistent storage.
Create a file named task-definition.yamland copy the following content.
AWSTemplateFormatVersion: '2010-09-09'
Description: Create ECS Task Definition for Bold Reports
Parameters:
TaskDefinitionFamily:
Type: String
Default: BoldReportsEC2
Description: ECS Task Definition Family Name
ExecutionRoleArn:
Type: String
Description: ECS Task Execution Role ARN
TaskRoleArn:
Type: String
Description: ECS Task Role ARN
EFSFileSystemId:
Type: String
Description: Existing Amazon EFS File System ID
AppBaseUrl:
Type: String
Description: Bold Reports Application URL
Resources:
BoldReportsTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: !Ref TaskDefinitionFamily
RequiresCompatibilities:
- EC2
NetworkMode: bridge
Cpu: "2048"
Memory: "8192"
ExecutionRoleArn: !Ref ExecutionRoleArn
TaskRoleArn: !Ref TaskRoleArn
RuntimePlatform:
CpuArchitecture: X86_64
OperatingSystemFamily: LINUX
Volumes:
- Name: BoldReports-volume
EFSVolumeConfiguration:
FileSystemId: !Ref EFSFileSystemId
RootDirectory: /
ContainerDefinitions:
- Name: boldreports
Image: syncfusion/boldreports
Essential: true
Cpu: 0
PortMappings:
- ContainerPort: 80
HostPort: 0
Protocol: tcp
Environment:
- Name: APP_BASE_URL
Value: !Ref AppBaseUrl
- Name: BOLD_SERVICES_HOSTING_ENVIRONMENT
Value: docker
- Name: BOLD_SERVICES_REVERSE_PROXY
Value: "true"
MountPoints:
- SourceVolume: BoldReports-volume
ContainerPath: /application/app_data
ReadOnly: false
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: /ecs/BoldReports
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: ecs
awslogs-create-group: "true"
Outputs:
TaskDefinitionArn:
Description: ECS Task Definition ARN
Value: !Ref BoldReportsTaskDefinition
Export:
Name: BoldReportsTaskDefinitionArn
Deploy the ECS Task Definition
Run the following command from the directory where task-definition.yaml is saved.
aws cloudformation deploy `
--template-file task-definition.yaml `
--stack-name boldreports-task `
--parameter-overrides `
TaskDefinitionFamily=BoldReportsEC2 `
ExecutionRoleArn=<ecs-task-execution-role-arn> `
TaskRoleArn=<ecs-task-role-arn> `
EFSFileSystemId=<efs-file-system-id> `
AppBaseUrl=https://reports.example.com
Verify the Deployment
After the deployment completes successfully:
- Open the CloudFormation console.
- Verify the boldreports-task stack is in the CREATE_COMPLETE state.
- Navigate to Amazon ECS → Task Definitions.
- Verify that the BoldReportsEC2 task definition has been created.
- Open the task definition and verify:
- The container image is syncfusion/boldreports.
- The container port is configured as 80.
- The Amazon EFS volume is mounted to /application/app_data.
- The CloudWatch Logs configuration is present.
Step 3 – Create the ECS Service
The ecs-service.yaml template creates an ECS Service in the existing ECS cluster. The service deploys the Bold Reports task definition and associates it with the Application Load Balancer Target Group that was created in the previous step.
The Target Group ARN is imported from the load-balancer stack using CloudFormation Export/Import, eliminating the need to hardcode the Target Group ARN.
Create a file named ecs-service.yaml and copy the following content.
AWSTemplateFormatVersion: '2010-09-09'
Description: Create ECS Service for Bold Reports
Parameters:
ClusterName:
Type: String
Description: Existing ECS Cluster Name
ServiceName:
Type: String
Default: BoldReportsService
TaskDefinitionFamily:
Type: String
Default: BoldReportsEC2
DesiredCount:
Type: Number
Default: 1
Resources:
BoldReportsService:
Type: AWS::ECS::Service
Properties:
ServiceName: !Ref ServiceName
Cluster: !Ref ClusterName
LaunchType: EC2
DesiredCount: !Ref DesiredCount
TaskDefinition: !Ref TaskDefinitionFamily
SchedulingStrategy: REPLICA
EnableECSManagedTags: true
DeploymentConfiguration:
MaximumPercent: 200
MinimumHealthyPercent: 100
LoadBalancers:
- TargetGroupArn: !ImportValue BoldReportsTargetGroupArn
ContainerName: boldreports
ContainerPort: 80
Deploy the ECS Service
Run the following command from the directory where ecs-service.yaml is saved.
aws cloudformation deploy `
--template-file ecs-service.yaml `
--stack-name boldreports-service `
--parameter-overrides `
ClusterName=<ecs-cluster-name> `
ServiceName=BoldReportsService `
TaskDefinitionFamily=BoldReportsEC2 `
DesiredCount=1
Verify the Deployment
After the deployment completes successfully:
- Open the CloudFormation console.
- Verify the boldreports-service stack is in the CREATE_COMPLETE state.
- Navigate to Amazon ECS → Clusters.
- Select the existing ECS cluster.
- Verify that the BoldReportsService service has been created.
- Open the Tasks tab and confirm that one task is in the RUNNING state.
- Navigate to EC2 → Target Groups and select boldreports-tg.
- Verify that the ECS instance is registered and the target health status is Healthy.
- Open the application URL configured for APP_BASE_URL and verify that the Bold Reports application loads successfully.