We're currently using Capifony and the ec2-capify plugin to do rolling deployments of our code to a set of instances behind an ELB. We also use CloudFront to manage static assets, which we version with a query string (e.g. ?v1 or ?v2).
We've stumbled across a rare issue regarding updating the asset version. If the current version is v1, and we do a rolling deployment of v2 one server at a time then the following can happen for requests on the v2 box:
- CloudFront is asked for v2 and misses.
- CloudFront goes to the ELB and asks for the asset.
- The ELB chooses a server and one of two things happens: Cloudfront hits one of the new deployed servers (serving v2) OR it hits the old servers (v1).
- Either way, Cloudfront stores the content as v2. In the case where it hit a v1 server, the content is served incorrectly.
Our current solution to this is we have to do another deploy with a new asset version.
Is there a way to force Cloudfront through the ELB to only hit one of our updated (v2) servers, and to ignore the v1's?
Or am I missing an alternate solution which would resolve the problem?