Search code examples
amazon-web-servicesamazon-ecsaws-fargate

Why does fargate default infrastructure involve one VPC and two subnets?


I would like to know what the underlying reasons why these resources are necessary. Specially curious about the two subnets requirement.

Even official AWS cloudformation templates for fargate setups do include these resources.


Solution

  • By providing two subnets you are actually providing two availability zones. It's a standard practice for AWS to distribute resources across AZs for high availability in case one zone would go under. A single subnet can not spread across two or more zones, therefore you are required to provide two.

    Fargates requires "Availability Zone Spread" placement strategy and by specifying subnets you implicitly specifying different AZs.