10

I'm kicking off a single ECS Fargate task with a command such as:

aws ecs run-task --cluster Fargate \
 --task-definition $ECR_REPO-run-setup 
 --overrides file:///tmp/ecs-overrides-db-migrate.txt \
 --count 1 --launch-type FARGATE \
 --network-configuration "awsvpcConfiguration={subnets=[$PUBLIC_SUBNET_1, $PUBLIC_SUBNET_2],securityGroups=[$FARGATE_SG],assignPubli cIp=ENABLED}"

There are no ECS services, tasks or instances at all running in my account at the moment. This is the response I get back:

{
    "failures": [
        {
            "reason": "Capacity is unavailable at this time. Please try again later or in a different availability zone"
        }
    ],
    "tasks": []
}

I don't even see a way to specify a different availability zone for a Fargate Task?

If I should just retry, how long should I wait before retries?

Ryan Shillington
  • 23,006
  • 14
  • 93
  • 108

1 Answers1

10

Withing a VPC you can create one or more subnets that correspond to an availability zone.

When launching your Fargate task you will notice the network-configuration parameter and associated awsvpcConfiguration. To specify multiple zones you can pass in multiple subnets. For example:

aws ecs run-task --cluster Fargate \
 --task-definition $ECR_REPO-run-setup 
 --overrides file:///tmp/ecs-overrides-db-migrate.txt \
 --count 1 --launch-type FARGATE \
 --network-configuration "awsvpcConfiguration={subnets=[$MY_SUBNET_IN_AZ1, 
$MY_SUBNET_IN_AZ2]

The VPC documentation in aws contains more helpful information: https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html#vpc-subnet-basics

Ryan Shillington
  • 23,006
  • 14
  • 93
  • 108
Roy Kachouh
  • 1,855
  • 16
  • 24
  • 1
    We're already putting in 2 subnets for 2 AZs. Do you think we'd have a better chance of getting Capacity if we had all 4 AZs setup? – Ryan Shillington Mar 22 '18 at 14:20
  • 2
    Ryan, curious -- did you eventually fix this? Do you know what you did? – ESRogs Nov 25 '20 at 17:56
  • 1
    Hey @ESRogs check this: https://www.theverge.com/2020/11/25/21719396/amazon-web-services-aws-outage-down-internet – gbrennon Nov 25 '20 at 20:14
  • 1
    Well, today AWS is having a huge outage: https://www.theverge.com/2020/11/25/21719396/amazon-web-services-aws-outage-down-internet But at the time, there weren't enough spot instance machines available to fulfill my request. Adding multiple subnets fixed it for me. – Ryan Shillington Nov 25 '20 at 20:22