Selecting Subnets for a Service in AWS Fargate

amazon-vpcamazon-web-servicesaws-fargatesubnet

enter image description here

As we can see in the picture above, I can select as many subnets as I want. Does it mean, the tasks in the service are created across these two subnets?

Suppose I have one task running, in which subnet will it run then?
If there are multiple tasks in the service, how are they distributed between these subnets? Is it something handled by Fargate and we shouldn't worry about?

What if I select a public subnet and a private subnet, I'm guessing it would be a mess in that case.

Sorry if these are noob questions, I'm new to AWS.

Best Answer

No question is noob. I have been working on Fargate since inception and I don't even know the answer to all of your questions! Anyway, what you see there are subnets that are eligible to launch tasks (as part of your service). If you have one task, it will be deployed to one of them (picked randomly). If you have many tasks, we will (best effort) spread them across all those. You would usually either pick either all public subnets or private subnets (depending on your architecture). Assuming the service allows you to pick heterogeneous subnets (which I am not sure about) I'd treat it as a logical configuration error.