[MUSIC] Another platform as a service that we're going to talk about is ama, Amazon's Elastic Beanstalk. So Elastic Beanstalk is an interesting platform as a service because. It provides many of the capabilities that we extept, expect of a platform as a service. So bundling together things like, the ability to interact with the database, the ability to automatically deploy your application, put it behind the load balancer scale it up and down as needed. But it also has some other interesting capabilities, because it was built on top of Amazon Web Services. And one of those interesting capabilities is that you can also take control of lower level details that you typically can't do, on other platforms as a service. So for example, on Amazon if you want to deploy to your own virtual machine image, then maybe has hardware specific features or has some special native libraries that you want to access. You can actually do that on Amazon. We're not going to talk about that today, but we are going to show you how you take your Spring Boot applications and can take them and modify them slightly so that you can quickly upload them to Amazon Elastic Beanstalk and have them live in the cloud. So let's walk through an example and see how we do this. So, if you'll take a look at the video service with Dynamo and DB and Beanstalk, this is an example that's going to use Amazon's database called Dynamo, which is a very fast database. As well as their Beanstalk service. And this is an extension of the previous Dynamo, application that we saw before. So if you haven't gone and set up that Dynamo application and created the DynamoDB tables that you'll need, for that application, you want to go ahead and do that first before watching this tutorial because this tutorial assumes that you've already set up the proper Dynamo tables. To persist video objects. Other than the setup, the of DynamoDB, the key thing that's different from the previous Spring Boot applications that we've done, are that we have added a application servlet initializer. And this is a simple class. That you can reuse over and over in your applications, that instead of having the applications main method actually go and kick off spring with an embedded servlet container, this simply tells a servlet container like Tomcat that's standalone that you're deploying this application into. To go and launch and configure itself using the application class. So this is very similar to what we saw, in previous examples where we used the main method to kick off, an embedded container. In this case we've just done something slightly different. Since we're going to be running in a standalone web application container. So rather than embedding Tomcat into our application. We're going to package our application into a web application resource or WAR file. And then deploy it into a Tomcat instance. So in order to that, we also have to specify a little bit of information to help that Tomcat instance. Bootstrap our code into itself and into the container. So we add this simple application servlet, initializer class which is going to tell Spring where our application configuration is. And it inherits from the Spring Boot servlet initializer. Which tells the web application container to do and set up a dispatcher servlet and some of those other things, that we've seen in the past. One other slight change is in the build.gradle file and that's, you want to make sure that you have, provided runtime rather than compile or something along the lines of that, for the Spring Boot's starter Tomcat dependency. And the reason for this is is is when you have provided runtime rather than compile. It tells Spring that it needs to package your application into a WAR file. So if you don't have this Spring won't necessarily package your application correctly into a WAR file. Luckily, the Spring Boot plug in for our gradle files will automatically build the war file that we need in order to go and deploy our application. To Amazon Elastic Beanstalk. So to do that, we're going to go ahead and first just Delete our bill directories, so that we can see that this is working. And then we're going to run the build.gradle file using the Task Quick Launcher. And we're going to, just going to run the build target, or tasks. And we'll see that this is going to go and run. And it was going to package all of our application together with Spring Boot and the needed dependencies, into a library that's underneath the build folder. And then you want to look in libs. And then it's going to be the video service Amazon Beanstalk 1.1.war. And, you can change this to whatever you want inside of your build.gradle file by simply going to baseName. And then, changing that to something else. And then changing the version. So, for example, if we go and increment our version number to 1.2, we can simply rerun, the Task Quick Launcher with build. And it will go a rebuild the chart, the WAR file for us, using the new name inversion. And we see that we've got the new WAR that's been constructed. So these WAR files are what we're going to be deploying to Amazon Elastic Beanstalk. Se let's switch over to Amazon's Elastic Beanstalk's, Web console and start the deployment process. Amazon actually also has an entire clips tool suite and set of command line tools, but we're going to do everything through the web based console, for this demo. So, first, we're going to go to Create a New Application. We're going to call this mobilecloud14_demo. We're going to create the application, the Environment here is we're going to make this a web server because we're running a web application container and we expect this thing to receive, HTTP requests. For the platform we're going to choose Tomcat which is a Java application server, it's a web application container that we can use. And we're going to go ahead and, keep the Environment type the same. That is, it's going to have a load balancing and autoscaling by default. So we'll go ahead and click through to Next. And the next part is where we're going to select our WAR file. So we're going to choose the file, and then. Inside of our build directory lives WAR, we're going to choose the WAR file that we just created. And we'll just simply hit Next, and this is going to upload our entire application, to Amazon Elastic Beanstalk. So that our WAR file can be deployed into the cloud. We've now got a identifier for our application and what we're going to see is that we get this identifier .elasticbeanstalk.com as a URL that we can use to access, our application. We're not going to create any additional relational databases for this application because we're going to be using DynamoDB instead. So we don't have to worry about that. We're going to just stick with the default instance, the t1 micro. But if you wanted to select one of Amazon's other server types as your default type, you could do that here. You could also select a SSH key pair that you had created through Amazon if you wanted to be able to SSH into your applications. The nice things about Spring Boot applications is they include, a health checking URL so by default your, your Spring Boot application has a URL called slash help that if a request is to, sent to it and the application is running it will return OK. Now this is important because. Amazon's load balancers need to know when a node fails for some reason, or some error has occurred, so that they can go and either shut that instance down and replace it with a new one, or take that into account in the load balancing. So this health check URL is going to be used by the underlying autoscaling infrastructure and the load balancing el, infrastructure. And we don't have to do anything. We get that for free with Spring Boot. We're going to go ahead and keep everything else, all of the other defaults the same, and we're just going to click through to the next screen. We don't have any specific Environment Tags, so we're going to skip through this. And, now we can go and launch, our application. Now, this application actually requires, some command line parame, parameters, some properties to be provided to the virtual machine. And, by default, they are not being provided. So one of the things that you need to do, is go to the Configuration section. And then under Software Configuration, we can decide parameters that we would like to be passed, to our application. So, if you remember, when, we wanted to launch our application, we had to specify in the run configuration clips, dash d and a parameter name. And we had a series of those that we had to specify. So, if you go to the application, these were the dash d parameters, that we were passing it in. So we would have dash d, AWS access key id. We had a slightly different naming for it in the other examples, but in this one we're going to use Amazon's identifiers for those properties that we can pass on the command line. In this case, AWS access key id. And AWS secret key. And, we will provide those properties right here, in the configuration. Once we have provided those properties, they'll automatically be passed to our instance when we launch it, and so you can go ahead and provide those properties, and then hit Save. We're going to go back to the Dashboard, and we see that Amazon is in the process of launching our application, which is going to take a little bit of time. While Amazon is going ahead and launching our application, let's take a look at some of the other features that we have available to us. As an a, a, app engine server, we can go and we can get the request Logs. And get, information about the server. In this case, our server hasn't launched yet, so there's no logs that are available to us yet. But once the server is launched, we'll be able to grab the logs. We can go and monitor our server and check its health once it's actually launched. We can also look for events related to the startup, of the application. In this case we can see that Amazon's in the process of creating an autoscaling configuration so that as load on our system increases, Amazon will automatically go and deploy new instances of our application in a virtual machine. And automatically start Tomcat and pass all of the correct parameters and WAR files to it. We can also set Alarms, for example, when something interesting happens that we want to know about, like the load gets too high or response time gets too long. We can set those types of things in Alarm. So this is the basic infrastructure that Amazon Elastic Beanstalk gives you. You can also go do in much richer configuration, but we're not going to get into those deeper details, but this is a very simple way, of getting a Spring Boot application up and running in the cloud. Now that our application has switched over to green, saying that it's healthy and it's running in the Amazon's cloud. We can actually go and access its URL at elasticbeansalk.com, to see that it's running. And in this case we've got our video service now running, and it's reporting back to us, that it has a slash video URL. So, that's it and that's all it took to go from our WAR file, clicking through a few simple screens on Amazon's cloud to actually deploy the WAR file into Elastic Beanstalk. And, at this point, it's helpful to understand that we've actually set up quite a bit of complicated infrastructure. We've got a load balancer, that's been set up by Amazon. It's now routing requests, to one or more virtual machines, that have been set up in Amazon's cloud. Each virtual machine has Tomcat running on it, Tomcat 7. With our app inside of it. We then got our app talking to Amazon's Dynamo database. And anytime that the load gets too high on our application, Amazon will automatically go and autoscale, our application to increase or decrease the number of virtual machines, that are needed to handle the traffic. So if it sees that the. The CPU utilization on a particular virtual machine is getting too high or some other trigger that we've set, it will automatically allocate new virtual machines, launch our application in them. And then when the, the CPU utilization or other metrics get too low, it will automatically take away virtual machines as needed. So, with a very simple bit of work, we now have. An application, that can receive requests to a URL at Elastic Beanstalk that was created for us. And, we can then route those requests across multiple virtual machines, that'll each start and run our application. Each of those can be connected to Dynamo's database. We also have access to all of the logs, for these virtual machines and these Tomcat instances as they're running. So, using Spring Boot, packaging our code into a WAR file and then deploying it to Amazon's Elastic Beanstalk is a very straightforward and simple process, to get your application running in the cloud.