Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how does swap environmental URL work exactly?

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.

like image 562
diogeneshamilton Avatar asked Jul 18 '12 23:07

diogeneshamilton


2 Answers

Please be careful here about which "Swap URL" feature is being discussed... If you are referring to the AWS Elastic Beanstalk "Actions" | "Swap Environment URLs" feature, my experience is that this feature has nothing to do with DNS and nothing to do with Route 53.

From what I can see, AWS EB Swap URL's simply swaps the public-facing URL's of your beanstalk environments... Keeping you from having to change your DNS at all.

Example:

Let's assume you have two EB environments:

"quality" with an EB URL of "quality-qq443224.elasticbeanstalk.com"

"quality-patched1" with an EB URL of "quality-patched1.elasticbeanstalk.com"

If you choose the "quality-patched1" instance and choose "Swap Environment URL's" with your "quality" instance... All that will happen is they will now be listed as:

"quality" with an EB URL of "quality-patched1.elasticbeanstalk.com"

"quality-patched1" with an EB URL of "quality-qq443224.elasticbeanstalk.com"

Therefore your EXISTING DNS CNAMEs (assumed to be in Route 53 and assumed to be pointing at /quality-qq443224.../) do not have to change at all... They will be directed to your new patched instance.

like image 173
Dave Collins Avatar answered Nov 12 '22 19:11

Dave Collins


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.

like image 30
yegor256 Avatar answered Nov 12 '22 20:11

yegor256