1 00:00:00,110 --> 00:00:03,700 ‫So here is a set of theory slides 2 00:00:03,700 --> 00:00:06,260 ‫around how to perform an Elastic Beanstalk Migration 3 00:00:06,260 --> 00:00:08,130 ‫because that can come up in the exam. 4 00:00:08,130 --> 00:00:10,230 ‫So the first one is a Load Balancer, 5 00:00:10,230 --> 00:00:12,540 ‫So after you create a Beanstalk environment 6 00:00:12,540 --> 00:00:15,700 ‫you cannot change the Elastic Load Balancer type, 7 00:00:15,700 --> 00:00:16,880 ‫only its configuration. 8 00:00:16,880 --> 00:00:18,140 ‫So we've seen this before 9 00:00:18,140 --> 00:00:20,090 ‫If you create a Classic Load Balancer 10 00:00:20,090 --> 00:00:22,580 ‫you can only edit the classical bouncer setting, 11 00:00:22,580 --> 00:00:25,760 ‫you cannot upgrade it to an Application Load Balancer. 12 00:00:25,760 --> 00:00:27,920 ‫So if you want it to somehow upgraded 13 00:00:27,920 --> 00:00:30,500 ‫from a Classic Load Balancer to an Application Load Balancer 14 00:00:30,500 --> 00:00:31,790 ‫or from an Application Load Balancer 15 00:00:31,790 --> 00:00:33,630 ‫to a Network Load Balancer. 16 00:00:33,630 --> 00:00:35,320 ‫You will need to perform a migration 17 00:00:35,320 --> 00:00:37,160 ‫and the steps are as such. 18 00:00:37,160 --> 00:00:39,640 ‫First you would create a new environment 19 00:00:39,640 --> 00:00:43,640 ‫with the same configuration except the Load Balancer. 20 00:00:43,640 --> 00:00:46,280 ‫And so we can't use the clone feature 21 00:00:46,280 --> 00:00:48,010 ‫we just saw in the past lecture 22 00:00:48,010 --> 00:00:50,370 ‫because the clone feature would copy 23 00:00:50,370 --> 00:00:53,550 ‫the exact same Load Balancer type and configuration. 24 00:00:53,550 --> 00:00:56,334 ‫So you have to recreate manually the same configuration 25 00:00:56,334 --> 00:00:59,130 ‫and then the old environment 26 00:00:59,130 --> 00:01:00,250 ‫will be copied 27 00:01:00,250 --> 00:01:02,260 ‫not cloned into a new environment 28 00:01:02,260 --> 00:01:03,890 ‫and this one in this new environment, 29 00:01:03,890 --> 00:01:06,310 ‫I will have my Application Load Balancer, 30 00:01:06,310 --> 00:01:08,270 ‫then we will deploy our application 31 00:01:08,270 --> 00:01:10,330 ‫onto the new environment. 32 00:01:10,330 --> 00:01:12,570 ‫And then we need to shift the traffic 33 00:01:12,570 --> 00:01:15,090 ‫from the old environment to the new environment. 34 00:01:15,090 --> 00:01:19,010 ‫So for this, we can do a CNAME swap or we can use Route 53 35 00:01:19,010 --> 00:01:22,200 ‫to do a DNS update either work, 36 00:01:22,200 --> 00:01:23,870 ‫hopefully that makes sense. 37 00:01:23,870 --> 00:01:26,490 ‫Next, we'll talk about RDS Elastic Beanstalk. 38 00:01:26,490 --> 00:01:30,410 ‫So RDS can be provisioned with your Beanstalk application, 39 00:01:30,410 --> 00:01:32,830 ‫which is great if you want to do development and test. 40 00:01:32,830 --> 00:01:34,720 ‫So this looks like this in your Beanstalk 41 00:01:34,720 --> 00:01:37,050 ‫you have your own RDS Database. 42 00:01:37,050 --> 00:01:40,140 ‫But if you are doing a production deployment, 43 00:01:40,140 --> 00:01:43,040 ‫this is not great because the database lifecycle 44 00:01:43,040 --> 00:01:46,700 ‫is going to be tied to the Beanstalk environment lifecycle. 45 00:01:46,700 --> 00:01:50,630 ‫So the best way to do it in prod is to separate 46 00:01:50,630 --> 00:01:53,350 ‫the RDS Database from your Beanstalk environment 47 00:01:53,350 --> 00:01:55,560 ‫and reference it using a connection string 48 00:01:55,560 --> 00:01:57,980 ‫for example using an environment variable. 49 00:01:57,980 --> 00:01:58,880 ‫So how would we do this? 50 00:01:58,880 --> 00:02:01,770 ‫How would we Decouple RDS if it's already 51 00:02:01,770 --> 00:02:03,590 ‫in our Beannstock stack? 52 00:02:03,590 --> 00:02:06,760 ‫Well, the first one we do is that we would create a snapshot 53 00:02:06,760 --> 00:02:09,990 ‫of our RDS Database as a safeguard in case things go wrong, 54 00:02:09,990 --> 00:02:13,140 ‫so we have a backup or data and we know we're good. 55 00:02:13,140 --> 00:02:15,270 ‫The next thing is to go to the RDS console 56 00:02:15,270 --> 00:02:18,410 ‫and protect the RDS Database from deletion. 57 00:02:18,410 --> 00:02:21,160 ‫This will prevent it from being deleted no matter what 58 00:02:21,160 --> 00:02:23,750 ‫then we create a new Elastic Beanstalk environment, 59 00:02:23,750 --> 00:02:25,460 ‫this time without RDS. 60 00:02:25,460 --> 00:02:27,140 ‫And we point our application 61 00:02:27,140 --> 00:02:29,710 ‫to the already existing RDS Database, 62 00:02:29,710 --> 00:02:31,740 ‫for example, using an environment variable. 63 00:02:31,740 --> 00:02:33,910 ‫So now we have the new environment pointing 64 00:02:33,910 --> 00:02:35,418 ‫to the same database. 65 00:02:35,418 --> 00:02:37,658 ‫Then we perform a CNAME swap, 66 00:02:37,658 --> 00:02:41,860 ‫so a blue/green deployment or route 53 DNS updates 67 00:02:41,860 --> 00:02:43,400 ‫and we confirm it's working. 68 00:02:43,400 --> 00:02:45,190 ‫So now we have shifted all the traffic 69 00:02:45,190 --> 00:02:47,200 ‫from the old version to the new version 70 00:02:47,200 --> 00:02:50,090 ‫then we terminate the old environment. 71 00:02:50,090 --> 00:02:53,340 ‫And because we have enabled RDS deletion protection 72 00:02:53,340 --> 00:02:54,173 ‫then 73 00:02:54,173 --> 00:02:55,680 ‫RDS will stay. 74 00:02:55,680 --> 00:02:58,360 ‫And then because it's the CloudFormation stack, 75 00:02:58,360 --> 00:03:01,290 ‫behind our Elastic Beanstalk environment will have failed 76 00:03:01,290 --> 00:03:04,430 ‫to be deleting it will be in the Delete Failed state. 77 00:03:04,430 --> 00:03:06,610 ‫And so we need to just go in CloudFormation 78 00:03:06,610 --> 00:03:09,450 ‫and delete that CloudFormation stack manually. 79 00:03:09,450 --> 00:03:11,640 ‫And there we go will have effectively 80 00:03:12,480 --> 00:03:14,970 ‫created an RDS Database on its own outside 81 00:03:14,970 --> 00:03:16,540 ‫of our Beanstalk environment. 82 00:03:16,540 --> 00:03:17,780 ‫So hope that was helpful 83 00:03:17,780 --> 00:03:19,730 ‫and I will see you in the next lecture.