1 00:00:00,180 --> 00:00:01,470 ‫Okay, so now let's talk about 2 00:00:01,470 --> 00:00:03,480 ‫Elastic Beanstalk Extensions. 3 00:00:03,480 --> 00:00:05,550 ‫So, when we create a zip file 4 00:00:05,550 --> 00:00:07,860 ‫it contains your code that must be deployed 5 00:00:07,860 --> 00:00:12,330 ‫to Elastic Beanstalk, but we can also add EB extensions. 6 00:00:12,330 --> 00:00:14,580 ‫So, all the parameters that we set in the UI 7 00:00:14,580 --> 00:00:17,460 ‫can also be configured with code, using files, 8 00:00:17,460 --> 00:00:19,560 ‫and these are the EB extensions. 9 00:00:19,560 --> 00:00:22,440 ‫So, the requirements that all these configuration files 10 00:00:22,440 --> 00:00:27,440 ‫must be in the .ebextensions/ directory 11 00:00:27,480 --> 00:00:29,370 ‫in the root of your source code. 12 00:00:29,370 --> 00:00:34,050 ‫Okay, so it has to be in a directory called .ebextensions/. 13 00:00:34,050 --> 00:00:36,960 ‫It must be in the YAML or JSON formats. 14 00:00:36,960 --> 00:00:39,630 ‫And even though it is in YAML or JSON format, 15 00:00:39,630 --> 00:00:44,040 ‫the extension of that file must end with .config. 16 00:00:44,040 --> 00:00:46,590 ‫For example, logging.config, okay? 17 00:00:46,590 --> 00:00:48,300 ‫It has to end with .config. 18 00:00:48,300 --> 00:00:50,160 ‫You are able to modify some defaults 19 00:00:50,160 --> 00:00:53,430 ‫using the options_settings document, 20 00:00:53,430 --> 00:00:54,780 ‫and we'll see this in a second. 21 00:00:54,780 --> 00:00:57,450 ‫And you have the ability to add resources 22 00:00:57,450 --> 00:01:01,320 ‫using the EB extensions, such as RDS, ElastiCache, DynamoDB 23 00:01:01,320 --> 00:01:04,620 ‫and all the other things that you cannot necessarily set 24 00:01:04,620 --> 00:01:06,990 ‫through the Elastic Beanstalk console. 25 00:01:06,990 --> 00:01:08,430 ‫So, by the way, 26 00:01:08,430 --> 00:01:11,430 ‫anything that is managed by the EB extensions 27 00:01:11,430 --> 00:01:13,710 ‫gets deleted if the environment goes away. 28 00:01:13,710 --> 00:01:15,480 ‫So that means that if you create, for example, 29 00:01:15,480 --> 00:01:18,630 ‫an ElastiCache as part of your Elastic Beanstalk environment 30 00:01:18,630 --> 00:01:20,850 ‫and then you delete your Elastic Beanstalk environment, 31 00:01:20,850 --> 00:01:23,430 ‫then your ElastiCache will go away as well. 32 00:01:23,430 --> 00:01:24,300 ‫So, let's go in the hands-on 33 00:01:24,300 --> 00:01:27,900 ‫to see how we can play with these EB extension files. 34 00:01:27,900 --> 00:01:31,260 ‫Okay, so here I am in my code directory. 35 00:01:31,260 --> 00:01:35,610 ‫And so, I've created a nodejs-v3-ebextensions directory, 36 00:01:35,610 --> 00:01:38,700 ‫and within it I created a .ebextensions directory, 37 00:01:38,700 --> 00:01:41,400 ‫and placed an environment-variables.config. 38 00:01:41,400 --> 00:01:45,270 ‫So, as we can see, this file ends with a .config, 39 00:01:45,270 --> 00:01:48,360 ‫and is placed within the .ebextensions directory. 40 00:01:48,360 --> 00:01:50,940 ‫And you have to do these two things for it to work. 41 00:01:50,940 --> 00:01:53,370 ‫Then the language, I can set it to YAML, 42 00:01:53,370 --> 00:01:54,900 ‫to show you some proper formatting. 43 00:01:54,900 --> 00:01:56,460 ‫So, even though it's a .config file 44 00:01:56,460 --> 00:01:58,350 ‫we can have a YMAL formatting. 45 00:01:58,350 --> 00:01:59,970 ‫And so, what did I say? 46 00:01:59,970 --> 00:02:01,980 ‫This is all the stuff I already told you. 47 00:02:01,980 --> 00:02:04,290 ‫And so here we set option_settings, 48 00:02:04,290 --> 00:02:06,210 ‫and I have the documentation reference 49 00:02:06,210 --> 00:02:07,650 ‫for this option settings. 50 00:02:07,650 --> 00:02:08,490 ‫So, here we set 51 00:02:08,490 --> 00:02:12,870 ‫the AWS Elastic Beanstalk application environment variables, 52 00:02:12,870 --> 00:02:14,910 ‫and here we can define the environment variables. 53 00:02:14,910 --> 00:02:18,300 ‫We can have the DB_URL to be equal to this URL, 54 00:02:18,300 --> 00:02:21,780 ‫and the DB_USER to have, for example, the value of username. 55 00:02:21,780 --> 00:02:23,340 ‫So, here it's just an example. 56 00:02:23,340 --> 00:02:25,770 ‫We're not using these in our application, 57 00:02:25,770 --> 00:02:27,660 ‫but if we wanted to connect, for example, 58 00:02:27,660 --> 00:02:29,910 ‫to an external RDS database, 59 00:02:29,910 --> 00:02:31,830 ‫maybe a Postgres RDS database, 60 00:02:31,830 --> 00:02:33,630 ‫then we will need to set up environment variables, 61 00:02:33,630 --> 00:02:36,450 ‫and we will set up this way, with an ebextension, 62 00:02:36,450 --> 00:02:38,850 ‫and we'll define the value of these right here. 63 00:02:38,850 --> 00:02:39,683 ‫So, this is good. 64 00:02:39,683 --> 00:02:41,850 ‫So, what I've done is that I've already zipped this 65 00:02:41,850 --> 00:02:45,780 ‫into the nodejs-V3-ebextensions.zip file. 66 00:02:45,780 --> 00:02:49,110 ‫So, let's go into our dev environment, 67 00:02:49,110 --> 00:02:50,190 ‫because this is going to be faster 68 00:02:50,190 --> 00:02:51,810 ‫to perform an update there. 69 00:02:51,810 --> 00:02:53,370 ‫We're going to upload and deploy, 70 00:02:53,370 --> 00:02:57,270 ‫and this time I will choose my nodejs-V3-ebextension 71 00:02:57,270 --> 00:02:58,830 ‫and the version it was going to be, 72 00:02:58,830 --> 00:03:01,623 ‫MyApplication-EBExtensionsDemo, 73 00:03:03,570 --> 00:03:04,623 ‫and click on Deploy. 74 00:03:05,700 --> 00:03:07,680 ‫And so, this new version is going to be deployed 75 00:03:07,680 --> 00:03:09,750 ‫directly to my single EC2 instance, 76 00:03:09,750 --> 00:03:10,890 ‫which should be rather quick, 77 00:03:10,890 --> 00:03:13,620 ‫but I'm going to pause the video until this is done. 78 00:03:13,620 --> 00:03:15,960 ‫So, my environment update is now done. 79 00:03:15,960 --> 00:03:16,793 ‫And let's verify 80 00:03:16,793 --> 00:03:19,200 ‫that the EBextensions file have been applied. 81 00:03:19,200 --> 00:03:22,530 ‫For this, let's go into Configuration, you scroll down, 82 00:03:22,530 --> 00:03:25,860 ‫and then here under Environment properties, 83 00:03:25,860 --> 00:03:28,680 ‫we can find the DB_URL and DB_USER 84 00:03:28,680 --> 00:03:32,280 ‫that have been set directly, not from me in the console, 85 00:03:32,280 --> 00:03:33,750 ‫but from the files deployed 86 00:03:33,750 --> 00:03:36,180 ‫as part of this application version. 87 00:03:36,180 --> 00:03:39,510 ‫So, we can really start to see the power of the EB files, 88 00:03:39,510 --> 00:03:42,180 ‫the EB config files of the EB extensions. 89 00:03:42,180 --> 00:03:43,620 ‫So, I hope that makes sense for you, 90 00:03:43,620 --> 00:03:44,760 ‫and we just crashed the surface, 91 00:03:44,760 --> 00:03:46,200 ‫but that's enough for the exam. 92 00:03:46,200 --> 00:03:49,200 ‫I hope you liked it, and I will see you in the next lecture.