I have a question regarding sticky sessions. Let's suppose that I have an ALB with two target groups attached with one EC2 instance in each of them.
The first request will be forwarded by ALB using the default rule of the listener (I guess it will choose one target group with round robin, because I gave both of them a weight of 1, but please correct me if I'm wrong here).
In my specific case I want the next requests to be sticky in a way that if I share the URL then they will be forwarded to the same target group (essentially to the same instance). I guess this can be achieved by path-based or query string based routing. So I added 2 rules to my listener, one of them forwards requests to Targetgroup1 if query string is "server=targetgroup1" and the same with Targetgroup2 if query string is "server=targetgroup2".
My main question is, how can I get the info where the ALB forwarded my first request (which was distributed by the ALB) and then how do I add it to the URL as a query parameter. In this case I would like to have "?server=targetgroup1" or "?server=targetgroup2" in my URL after the first request. Is there any better way to solve this problem where I need sticky sessions with shareable URL-s that forward me to the same node?