Install BDOT Collector in AWS ECS EC2
Deploy BDOT Collector on AWS ECS EC2 for cost-effective, scalable collector deployment with full control over underlying infrastructure.
Prerequisites
Quick Deployment with CloudFormation
CloudFormation Template
AWSTemplateFormatVersion: '2010-09-09'
Description: 'BDOT Collector on AWS ECS EC2 with Auto Scaling and VPC'
Parameters:
CollectorSecretKey:
Type: String
Description: BDOT Collector secret key from Bindplane Server
NoEcho: true
OpampEndpoint:
Type: String
Description: OpAMP endpoint URL
Default: 'wss://app.bindplane.com/v1/opamp'
AllowedPattern: '^(ws|wss)://.*'
CollectorImage:
Type: String
Description: BDOT Collector Docker image
Default: 'ghcr.io/observiq/bindplane-agent:1.84.0'
Environment:
Type: String
Description: Environment name (used for resource naming)
Default: prod
AllowedValues: [dev, staging, prod]
InstanceType:
Type: String
Description: EC2 instance type for ECS cluster
Default: t3.medium
AllowedValues: [t3.small, t3.medium, t3.large, t3.xlarge, m5.large, m5.xlarge]
MinSize:
Type: Number
Description: Minimum number of EC2 instances
Default: 1
MinValue: 1
MaxValue: 10
MaxSize:
Type: Number
Description: Maximum number of EC2 instances
Default: 5
MinValue: 1
MaxValue: 20
DesiredCapacity:
Type: Number
Description: Desired number of EC2 instances
Default: 2
MinValue: 1
MaxValue: 10
Resources:
# VPC and Networking
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsHostnames: true
EnableDnsSupport: true
Tags:
- Key: Name
Value: !Sub '${Environment}-bindplane-collector-vpc'
# Internet Gateway
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: !Sub '${Environment}-bindplane-collector-igw'
InternetGatewayAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
InternetGatewayId: !Ref InternetGateway
VpcId: !Ref VPC
# Public Subnets
PublicSubnet1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [0, !GetAZs '']
CidrBlock: 10.0.1.0/24
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: !Sub '${Environment}-bindplane-collector-public-1a'
PublicSubnet2:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [1, !GetAZs '']
CidrBlock: 10.0.2.0/24
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: !Sub '${Environment}-bindplane-collector-public-1b'
# Route Tables
PublicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub '${Environment}-bindplane-collector-public-rt'
DefaultPublicRoute:
Type: AWS::EC2::Route
DependsOn: InternetGatewayAttachment
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
PublicSubnet1RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref PublicRouteTable
SubnetId: !Ref PublicSubnet1
PublicSubnet2RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref PublicRouteTable
SubnetId: !Ref PublicSubnet2
# Security Groups
CollectorSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Security group for BDOT Collector
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 4317
ToPort: 4317
CidrIp: 0.0.0.0/0
Description: OTLP gRPC
- IpProtocol: tcp
FromPort: 4318
ToPort: 4318
CidrIp: 0.0.0.0/0
Description: OTLP HTTP
- IpProtocol: tcp
FromPort: 13133
ToPort: 13133
CidrIp: 0.0.0.0/0
Description: Health check
- IpProtocol: tcp
FromPort: 55679
ToPort: 55679
CidrIp: 0.0.0.0/0
Description: ZPages debugging
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0
Description: SSH access
Tags:
- Key: Name
Value: !Sub '${Environment}-bindplane-collector-sg'
# IAM Roles
TaskExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
Tags:
- Key: Name
Value: !Sub '${Environment}-bindplane-collector-execution-role'
TaskRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Action: sts:AssumeRole
Tags:
- Key: Name
Value: !Sub '${Environment}-bindplane-collector-task-role'
ECSInstanceRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: ec2.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role
Tags:
- Key: Name
Value: !Sub '${Environment}-bindplane-collector-instance-role'
ECSInstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Roles:
- !Ref ECSInstanceRole
# CloudWatch Log Group
LogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub '/ecs/${Environment}-bindplane-collector'
RetentionInDays: 30
# ECS Cluster
ECSCluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: !Sub '${Environment}-bindplane-collector-cluster'
# Launch Template
LaunchTemplate:
Type: AWS::EC2::LaunchTemplate
DependsOn: ECSInstanceProfile
Properties:
LaunchTemplateName: !Sub '${Environment}-bindplane-collector-lt'
LaunchTemplateData:
ImageId: !Sub '{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}'
InstanceType: !Ref InstanceType
IamInstanceProfile:
Arn: !GetAtt ECSInstanceProfile.Arn
SecurityGroupIds:
- !Ref CollectorSecurityGroup
UserData:
Fn::Base64: !Sub |
#!/bin/bash
echo ECS_CLUSTER=${ECSCluster} >> /etc/ecs/ecs.config
echo ECS_ENABLE_TASK_ENI=true >> /etc/ecs/ecs.config
BlockDeviceMappings:
- DeviceName: /dev/xvda
Ebs:
VolumeSize: 30
VolumeType: gp3
# Auto Scaling Group
AutoScalingGroup:
Type: AWS::AutoScaling::AutoScalingGroup
DependsOn: LaunchTemplate
Properties:
AutoScalingGroupName: !Sub '${Environment}-bindplane-collector-asg'
LaunchTemplate:
LaunchTemplateId: !Ref LaunchTemplate
Version: !GetAtt LaunchTemplate.LatestVersionNumber
MinSize: !Ref MinSize
MaxSize: !Ref MaxSize
DesiredCapacity: !Ref DesiredCapacity
VPCZoneIdentifier:
- !Ref PublicSubnet1
- !Ref PublicSubnet2
HealthCheckType: EC2
HealthCheckGracePeriod: 300
Tags:
- Key: Name
Value: !Sub '${Environment}-bindplane-collector-instance'
PropagateAtLaunch: true
# ECS Task Definition
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: !Sub '${Environment}-bindplane-collector'
NetworkMode: host
RequiresCompatibilities:
- EC2
Cpu: 512
Memory: 1024
ExecutionRoleArn: !Ref TaskExecutionRole
TaskRoleArn: !Ref TaskRole
ContainerDefinitions:
- Name: bdot-collector
Image: !Ref CollectorImage
PortMappings:
- ContainerPort: 4317
Protocol: tcp
- ContainerPort: 4318
Protocol: tcp
- ContainerPort: 13133
Protocol: tcp
- ContainerPort: 55679
Protocol: tcp
Environment:
- Name: OPAMP_ENDPOINT
Value: !Ref OpampEndpoint
- Name: OPAMP_SECRET_KEY
Value: !Ref CollectorSecretKey
- Name: OPAMP_LABELS
Value: !Sub 'environment=${Environment},platform=aws-ecs-ec2'
- Name: MANAGER_YAML_PATH
Value: /etc/otel/storage/manager.yaml
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref LogGroup
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: ecs
# ECS Service
ECSService:
Type: AWS::ECS::Service
Properties:
ServiceName: !Sub '${Environment}-bindplane-collector-service'
Cluster: !Ref ECSCluster
TaskDefinition: !Ref TaskDefinition
DesiredCount: !Ref DesiredCapacity
LaunchType: EC2
Outputs:
VPCId:
Description: VPC ID
Value: !Ref VPC
Export:
Name: !Sub '${Environment}-bindplane-collector-vpc-id'
ECSClusterName:
Description: ECS Cluster Name
Value: !Ref ECSCluster
Export:
Name: !Sub '${Environment}-bindplane-collector-cluster-name'
ServiceName:
Description: ECS Service Name
Value: !Ref ECSService
Export:
Name: !Sub '${Environment}-bindplane-collector-service-name'
TaskDefinitionArn:
Description: ECS Task Definition ARN
Value: !Ref TaskDefinition
Export:
Name: !Sub '${Environment}-bindplane-collector-task-definition-arn'
AutoScalingGroupName:
Description: Auto Scaling Group Name
Value: !Ref AutoScalingGroup
Export:
Name: !Sub '${Environment}-bindplane-collector-asg-name'Deploy with CloudFormation
Architecture Overview
Container Architecture
Manual Deployment Steps
Step 1: Set Up AWS Infrastructure
Step 2: Create ECS Resources
Step 3: Create Launch Template and Auto Scaling Group
Step 4: Create Task Definition
Step 5: Create ECS Service
Configuration and Management
Connecting to Bindplane Server
Scaling Collectors
Monitoring and Logging
TLS Configuration
Troubleshooting
Common Issues
Best Practices
Cleanup
Next Steps
Last updated
Was this helpful?