(make sure that the MEMORY allocated to the containers is compatible with all machine types)
In the fleet file, triplicate the multi-subnet ‘Launch specification’ block (current DCP walks through the list of instances in the config file and matches each one with a launch specification):
{
"IamFleetRole": "arn:aws:iam::XXXXXXXXX:role/aws-ec2-spot-fleet-tagging-role",
"AllocationStrategy": "lowestPrice",
"TerminateInstancesWithExpiration": true,
"LaunchSpecifications": [
{
"ImageId": "ami-0ce03502c5bb5e188",
"SubnetId": "subnet-AAAAAAAAA, subnet-BBBBBBBBB, subnet-CCCCCCCCC, subnet-DDDDDDDDD",
"KeyName": "KEYNAME",
"IamInstanceProfile": {
"Arn": "arn:aws:iam::XXXXXXXXX:instance-profile/ecsInstanceRole"
},
"SecurityGroups": [
{
"GroupId": "sg-ZZZZZZZZZ"
}
],
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"DeleteOnTermination": true,
"VolumeType": "gp3",
"VolumeSize": 24,
"SnapshotId": "snap-0a7b4ece894d62882"
}
},
{
"DeviceName": "/dev/xvdcz",
"Ebs": {
"DeleteOnTermination": true,
"VolumeType": "gp3"
}
}
]
},
{
"ImageId": "ami-0ce03502c5bb5e188",
"SubnetId": "subnet-AAAAAAAAA, subnet-BBBBBBBBB, subnet-CCCCCCCCC, subnet-DDDDDDDDD",
"KeyName": "KEYNAME",
"IamInstanceProfile": {
"Arn": "arn:aws:iam::XXXXXXXXX:instance-profile/ecsInstanceRole"
},
"SecurityGroups": [
{
"GroupId": "sg-ZZZZZZZZZ"
}
],
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"DeleteOnTermination": true,
"VolumeType": "gp3",
"VolumeSize": 24,
"SnapshotId": "snap-0a7b4ece894d62882"
}
},
{
"DeviceName": "/dev/xvdcz",
"Ebs": {
"DeleteOnTermination": true,
"VolumeType": "gp3"
}
}
]
},
{
"ImageId": "ami-0ce03502c5bb5e188",
"SubnetId": "subnet-AAAAAAAAA, subnet-BBBBBBBBB, subnet-CCCCCCCCC, subnet-DDDDDDDDD",
"KeyName": "KEYNAME",
"IamInstanceProfile": {
"Arn": "arn:aws:iam::XXXXXXXXX:instance-profile/ecsInstanceRole"
},
"SecurityGroups": [
{
"GroupId": "sg-ZZZZZZZZZ"
}
],
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"DeleteOnTermination": true,
"VolumeType": "gp3",
"VolumeSize": 24,
"SnapshotId": "snap-0a7b4ece894d62882"
}
},
{
"DeviceName": "/dev/xvdcz",
"Ebs": {
"DeleteOnTermination": true,
"VolumeType": "gp3"
}
}
]
}
],
"Type": "maintain"
}
h/t @emiglietta
In config:
MACHINE_TYPE = ['m5.xlarge','c5.xlarge','c4.xlarge'](make sure that the MEMORY allocated to the containers is compatible with all machine types)
In the fleet file, triplicate the multi-subnet ‘Launch specification’ block (current DCP walks through the list of instances in the config file and matches each one with a launch specification):