How to register service that has multiple version

we are planning to host more than one version of web-api, do I have to treat each version as a separate service?

Eg: http://rooturl/v1/Students
http://rooturl/v2/students

You do not necessarily have to register them separate services. It is possible to advertise each instance under the same service name, and specify the API version for the given instance under the meta key on the Service Definition. See the examples on that page for more detail.

You’ll then want to create a Prepared Query (one for each advertised version) to be used for service discovery via either the DNS or HTTP interfaces to return service instances that provide the desired version of the web API.

If you’re utilizing Connect, you can create a Service Router which routes the different HTTP paths (i.e., /v1 or /v2) to specific service subsets associated with each API version. Service subsets are defined in a Service Resolver you create for the web-api service. See L7 Traffic Management for more info.

thank you for answering my question. I think I understand what you meant, but, I do have question with regard of multiple instance of same service running on different EC2 instance, I meant, ECS cluster, we are supposed to have one Consul Client/agent running on one EC2, I understand how to register one service running on one instance with local Consul Agent, but, it is possible that same service/task can be running on another EC2, how does the service registration looks like? and how to discover a service in a ECS cluster?