1 00:00:00,030 --> 00:00:04,950 Welcome back to backspace Academy in this hands-on session I'm going to 2 00:00:04,950 --> 00:00:10,170 demonstrate how to use the Elastic Beanstalk service to launch multiple 3 00:00:10,170 --> 00:00:15,480 environments and then use those multiple environments in a Blue Green deployment 4 00:00:15,480 --> 00:00:21,930 to update our code, okay so starting off in the Elastic Beanstalk management 5 00:00:21,930 --> 00:00:26,039 console this time I'm going to go to the top right-hand side here and click on 6 00:00:26,039 --> 00:00:34,410 create new application, we'll just give our application a name and click on 7 00:00:34,410 --> 00:00:40,379 create and so that will create a base Elastic Beanstalk application and we can 8 00:00:40,379 --> 00:00:45,420 create environments that are associated with that application 9 00:00:45,420 --> 00:00:50,820 we'll do that now, so we just go to actions and create environment 10 00:00:50,820 --> 00:00:55,590 it's a web server environment and we'll leave the environment name or we give it 11 00:00:55,590 --> 00:01:03,899 environment - one that's fine now platform will be NodeJS and we're 12 00:01:03,899 --> 00:01:08,310 still again going to just use a sample application and we're not going to 13 00:01:08,310 --> 00:01:12,510 configure any more options we just want to launch this to a single instance 14 00:01:12,510 --> 00:01:21,000 to make it quite quick and easy, so we'll create that environment, now while that 15 00:01:21,000 --> 00:01:25,229 environment is creating, we'll just jump back into our blue-green application and 16 00:01:25,229 --> 00:01:29,630 I'm going to create another environment 17 00:01:33,650 --> 00:01:38,400 and we'll call this one environment - 2 and exactly the same as before 18 00:01:38,400 --> 00:01:44,490 a nodejs application and again we'll use the sample application as before and we 19 00:01:44,490 --> 00:01:47,700 won't configure any more options and we'll create an environment so we have 20 00:01:47,700 --> 00:01:56,520 two identical environments that will be launched right now okay so after quite a 21 00:01:56,520 --> 00:02:00,570 few minutes we're going to have our second environment up and running and if 22 00:02:00,570 --> 00:02:06,630 we click on the URL for that environment we can see there we've got our AWS 23 00:02:06,630 --> 00:02:11,190 sample code for nodejs if we go back into our application here our blue-green 24 00:02:11,190 --> 00:02:13,900 application we can see our two environments, we click on our 25 00:02:13,900 --> 00:02:18,970 environment they've created we should be seeing the same thing as well and that's 26 00:02:18,970 --> 00:02:24,310 fine so what we need to do now is go back into our application and we look at 27 00:02:24,310 --> 00:02:29,500 application versions and so there we can see is that the AWS sample application 28 00:02:29,500 --> 00:02:33,700 has been deployed to both of these environments over here so environment 1 29 00:02:33,700 --> 00:02:37,569 environment two so what I'm going to do is I'm going to download that so I 30 00:02:37,569 --> 00:02:44,110 just click on that and that'll take us to the documentation and we can download 31 00:02:44,110 --> 00:02:47,560 the sample nodejs application from there so I'll just click on that and download 32 00:02:47,560 --> 00:02:57,010 that now after I've downloaded and extracted that zip file what I can do 33 00:02:57,010 --> 00:03:01,480 then is that I can look at modifying this code so I'm just going to open up 34 00:03:01,480 --> 00:03:09,879 this index.html and just going to edit it in notepad and it's going to scroll 35 00:03:09,879 --> 00:03:13,629 down to where it says the text column and I'm just going to change the 36 00:03:13,629 --> 00:03:17,170 background color of that to it's currently green I'm just going to change 37 00:03:17,170 --> 00:03:25,389 that to the blue and then save that and then what I'm going to do is to zip that 38 00:03:25,389 --> 00:03:34,569 back up again so I just select everything and see if that's so what I 39 00:03:34,569 --> 00:03:39,700 can do now so I can upload that updated code to Elastic Beanstalk and we should 40 00:03:39,700 --> 00:03:44,019 have a blue application going there, so I'm going to do that to the second 41 00:03:44,019 --> 00:03:51,819 environment, so I click on the environments tab here and I'll select 42 00:03:51,819 --> 00:03:56,739 the second environment and I'm going to upload and deploy our new code so I'll 43 00:03:56,739 --> 00:04:00,900 just click on that I'll choose that file 44 00:04:06,750 --> 00:04:18,880 and deploy that now after a certain amount of time we're going to have that 45 00:04:18,880 --> 00:04:22,600 deployed on our second environment but I'll give it a try now if I click on 46 00:04:22,600 --> 00:04:26,370 this endpoint we hopefully have a blue yes we have a blue background there now 47 00:04:26,370 --> 00:04:31,750 so we changed our code we updated that to the second environment and there we 48 00:04:31,750 --> 00:04:38,230 can see that it has come through fine if we go back to our first environment that 49 00:04:38,230 --> 00:04:46,000 will still be green so just say that we have our domain name that is pointed to 50 00:04:46,000 --> 00:04:52,720 this endpoint here and what we want to do is that we want to we don't want to 51 00:04:52,720 --> 00:04:57,100 go into route 53 and change CNAMEs and whatever and muck around like that we 52 00:04:57,100 --> 00:05:02,200 just want a very quick way to swap over from our production environment to our 53 00:05:02,200 --> 00:05:05,440 development environment and then make our development environment our 54 00:05:05,440 --> 00:05:08,860 production environment and so the quickest way to do that is is with 55 00:05:08,860 --> 00:05:15,280 Elastic Beanstalk by doing a URL swap and it'll swap the URL for this 56 00:05:15,280 --> 00:05:20,560 environment to the other environment so then your domain that is being pointed 57 00:05:20,560 --> 00:05:25,990 to this URL will alter all of a sudden be pointed to the other environment so 58 00:05:25,990 --> 00:05:33,370 let's give that a go. So what we do is we go into actions and then we do swap 59 00:05:33,370 --> 00:05:37,840 environment URLs so that's going to just swap this endpoint here for the 60 00:05:37,840 --> 00:05:45,070 endpoint of the other environment so we slick their environment number two is 61 00:05:45,070 --> 00:05:50,169 that the environment that we want to swap to and we click on swap and that 62 00:05:50,169 --> 00:05:55,780 will take a while to happen so after a few minutes we're going to see that the 63 00:05:55,780 --> 00:06:01,570 the URLs for these two environments have swapped so now our environment number 64 00:06:01,570 --> 00:06:08,110 one which was which had our green background is now going to be pointing 65 00:06:08,110 --> 00:06:13,060 at at the URL that was previously for environment number two we can see 66 00:06:13,060 --> 00:06:17,610 they're in - - now we go to the second environment 67 00:06:17,610 --> 00:06:22,029 so remember this is the environment that had the blue background it is now 68 00:06:22,029 --> 00:06:26,919 pointing or is our using the URL for the first environment so if we've got our 69 00:06:26,919 --> 00:06:33,340 domain name pointed to this URL here now that means that all of a sudden we're 70 00:06:33,340 --> 00:06:36,849 going to get the updated code and it's going to happen instantaneously so we 71 00:06:36,849 --> 00:06:42,460 click on that we should get a blue background and there we go so we have 72 00:06:42,460 --> 00:06:48,550 our environment one or that was our originally our environment one URL is 73 00:06:48,550 --> 00:06:54,430 now pointing to the environment number two which has our blue background so 74 00:06:54,430 --> 00:07:00,610 that's how a Bluegreen deployment works and obviously our environment number one 75 00:07:00,610 --> 00:07:04,120 or our original environment will now become our development environment and 76 00:07:04,120 --> 00:07:07,930 vice versa and so that's the way it works so what we can do now is that we 77 00:07:07,930 --> 00:07:12,879 can clean this all up and again we go to all applications and delete that 78 00:07:12,879 --> 00:07:16,990 application and delete so it'll delete the application and it would delete 79 00:07:16,990 --> 00:07:21,009 those two environments as well so we get his check on that we can see that the 80 00:07:21,009 --> 00:07:25,539 determinating those environments so that brings us to the end of a pretty long 81 00:07:25,539 --> 00:07:30,099 hands-on session I don't expect you to do this yourself it's not a lab because 82 00:07:30,099 --> 00:07:34,509 there's quite a little bit going on here but it's good to understand exactly how 83 00:07:34,509 --> 00:07:40,439 a Bluegreen environment works I look forward to seeing you in the next one