我有一个状态机,它由一个 Map 任务组成,它启动了许多 Fargate 任务(30+)一个非常相似的任务定义。任务之间的唯一区别是ContainerOverrides
块中的环境变量。
任务定义:
"CalculateTask": {
"Type": "Task",
"Resource": "arn:aws:states:::ecs:runTask.sync",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"IntervalSeconds": 10,
"MaxAttempts": 2,
"BackoffRate": 1.5
}
],
"Parameters": {
"LaunchType": "FARGATE",
"Cluster": "arn:aws:ecs:region:111111111:cluster/cluster-name",
"TaskDefinition": "arn:aws:ecs:region:111111111:task-definition/task-definition:44",
"NetworkConfiguration": {
"AwsvpcConfiguration": {
"Subnets": [
"subnet-1111111111111111","subnet-2222222222222222","subnet-3333333333333333"
],
...
}
},
"Overrides": {
"ContainerOverrides": [
{
"Name": "Phase-1-start",
"Environment": [
{
"Name": "COMMAND",
"Value": "calculateGas/Oil/PeakGas..."
}
]
}
]
}
}
}
当我运行我的 State Machibe 任务时,总是失败StoppedReason
:
"StopCode": "TaskFailedToStart",
"StoppedAt": 1618584363236,
"StoppedReason": "Unexpected EC2 error while attempting to Create Network Interface with public IP assignment
enabled in subnet 'subnet-2222222222222222': InsufficientFreeAddressesInSubnet",
我不明白为什么会出现这个问题,我提供了 3 个子网 ID 供 ECS 选择。