I recently used swap environmental URL to upgrade my Elastic Beanstalk application, using two environments. I have a CNAME record at a different URL mapped to the beanstalk URL. I tried then to push to the production environment(which now was at the test URL), and then swapped again, but this seemed to not work correctly.
I would expect the swap to map the test environment to the production URL, meaning that when I was previously pushing to the test environment to test, now I should push to the production environment, then swap to make another zero-downtime upgrade. This can be very confusing, so I was hoping someone can shed light on this, as there seems to be adearth of information about Elastic Beanstalk and swapping URLs.
URL swap is a simple operation of exchanging CNAMEs between two Green/Ready environments. It has nothing to do with Route 53 (or any other DNS). The only thing that it does is just exchanging of two CNAMEs. For example, you have one environment foo-1
with CNAME foo-1.example.com
, and another one foo-2
with CNAME foo-2.example.com
. After swap operation environment foo-1
will respond at http://foo-2.example.com
.
This operation is required in order to deploy a new version of your application with zero downtime. Your DNS will point your www.example.com
to foo-1
, which is changed on fly by a-few-seconds CNAME swap. Users won't see any delays, provided your application knows how to share resources (a database, for example).
You can take a look at jcabi-beanstalk-maven-plugin (I'm a developer). This Maven plugin does exactly this CNAME swap operation in a fully automated manner.