Amazon AWS Certified Developer Associate – Elastic Beanstalk
1. Using Elastic Beanstalk
Do a brief overview of what elastic beanstalk actually is. So with elastic beanstalk, you can deploy, monitor, and scale an application very, very quickly. And it provides developers or end users with the ability to provision an application infrastructure in an almost transparent way. So essentially, elastic beanstalk was created as a service for AWS, and it basically allows developers to just upload their code, so it might be just their code to their website.
For example, the HTML files, the PHP files, whatever, you zip it all up, you upload it to elastic beanstalk. And then elastic beanstalk will then provision the underlying resources underneath. So things like your elastic load balances, things like your EC, two instances, it can even provision RDS database servers for you. And we’ll come to that in a bit. Essentially, it’s a gooey for AWS, in that you don’t need to know anything about AWS. Elastic beanstalk will basically take care of all of the provisioning for you.
And the reason Amazon invented this service is because they wanted developers who don’t have much AWS experience to start deploying their applications to AWS. So it has a highly abstract focus towards infrastructure, focusing on components and performance and not configuration and specifications. Now, we’re going to go into cloud formation in the next section of the course, and cloud formation gives you a hell of a lot more control than elastic beanstalk.
And I said elastic beanstalk was a gui. Cloud formation allows you to go down to the very actual code itself, so it’s an adjacent format, and we’ll go into cloud formation in the next section of the course. Elastic beanstalk attempts to remove or significantly simplify infrastructure management, allowing applications to be deployed into infrastructure environments easily.
So the thing that I like to think of beanstalk is basically, elastic beanstalk is for people who don’t know how to use AWS, and they want to deploy their code to the cloud very, very quickly and get it all up and running. Now, that being said, of course, a lot of people do use elastic beanstalk who do know AWS inside out. They just want something that’s very easy to manage, something that’s able to provision environments very quickly.
They don’t have to write these massive cloud formation templates. But elastic beanstalk is primarily aimed at beginners and not necessarily production workloads. I know people are going to argue with me about this, but that’s my opinion anyway. So let’s look at some key architectural components of elastic beanstalk. So your applications are at the high level structure in beanstalk.
You either have your entire application as one elastic beanstalk application, or you can actually have each logical component of your application can be its own elastic beanstalk application or elastic beanstalk environment within an application. So you might have your web tier as just its own elastic beanstalk application. Then your application tier might be its own independent elastic beanstalk application. And applications can have multiple environments.
So you can have prods, you can have staging, you can have dev, you can have different versions of version one, version two, et cetera, or you can have your different functional types. Like I was just saying, so you’ve got your front end, which is your web servers, or your back end, which is your database. Servers and environments are either single instances or they can be scalable, so you can have them behind auto scaling groups and configure that yourself. Environments are either web server environments or worker environments. And application versions are unique packages which represent versions of your apps. And an application is uploaded to Elastic Beanstalk as an application bundle or as a zip file. And we’ll see how we do that in the lab in a couple of minutes. Each application has many different versions, so you can have a one to M relationship, so you can have basically an unlimited number of versions within Elastic Beanstalk. And application versions can be deployed to environments within an application as well. So let’s go ahead and jump into the AWS console and we’ll start getting our hands dirty with Elastic Beanstalk.
Okay, so here I am in the AWS console, and you’ll be able to see Elastic Beanstalk here under the Compute Services. I actually personally think it should be under the management tools because that’s where cloud formation is, that’s where OpsWorks is. Elastic Beanstalk is quite similar, but it is under Compute. So go in and click in it. If you’ve never done it before, you’ll get this splash screen. Just take a note of what region I’m in right now. So I’m in the Irish region, so if anything does look different, maybe just change your region over to the same region as me. So going to go ahead and hit get started. So in here we enter in our application name. So we’re creating a basic web application. It says create a new application and environment with sample applications or your own code. So I’m going to call this my hello, world app. And then in here we’ve got our base configuration, so we have to choose a platform. And then you can see here we’ve got pre configured, which is just our normal pre configured environments. We then have our pre configured Docker images, and then we all Docker environments. And then we have our Generic.
So I’m going to go through and I’m going to do a PHP environment. Now I want you to realize that when you’re going into the exam, this is the sort of thing you’re going to be tested on. They will be basically be asking you which applications you can deploy to Elastic Beanstalk. So it is worth getting to know these pre configured environments here. So node JS PHP python ruby Tomcat net so that’s windows and IIS java go and pack if you can remember those going into the exam, then you’re going to pick up a couple of points. So I’m going to go ahead and click on PHP. I’m going to use a sample application. So we’re going to use Amazon sample code. If you wanted to upload your own code, you would just click in here and go upload and I could just click here and create an application. It’s going to create it very, very quickly. But if I want more advanced options, we can click in here and go to configure more options. And this will help us set things up, like auto scaling, for example. So here’s our configuration presets.
Do we want it low cost? So free tier eligible? Do we want it highly available? Do we want a custom configuration? I’m going to say for the purposes of this lecture, it’s highly available. You can go for low cost, it doesn’t really matter. In here we can add our tags, so our tags could be our app name, so we could say my Hello World app and then maybe our department. So this might be done by the marketing department, et cetera. So you can add in all your tags and then basically any resources that Elastic Beanstalk is going to provision will have these tags attached to it. Moving on to software. In here we can do things. You’ve got our different container options.
So if we were using docker containers, this would be populated with other things. We can use our S Three log storage. So we can actually put all our instances, log files into S Three and rotate them. And that’s going to cost you the standard S Three charges, going to leave that as not enabled. You can also configure Cloud Watch logs and do log streaming. So this will stream your logs to Cloud Watch and you can set the retention up to ten years and configure Elastic Beanstalk to delete the logs when you terminate your environment. Again, I’m just going to leave this all blank. I’m not really interested in logging everything because I’m going to tear this down anyway. In here we have our instances. You can just see it there. So go ahead and click Modify.
So in here we have our instance types. So we can do T one micro, t two nano. You’ve got all your different instance types, dr. McGift picks, if you still remember that acronym. So I’m just going to do a T one micro, your AMI ID. So this is where you enter in the ID for your Amazon machine image. It’s a little bit annoying in that it’s not a very nice GUI. So you have to basically go back to the EC Two section, go to provision an instance and get the right EC Two AMI. But you just enter it in there. Here’s your root volume. So your root device volume. If you want magnetic or general purpose SSD or provision to IOPS, you just select in here. If you click in Magnetic then or any of these, you need to specify what size. I’m just going to use the default one for this AMI ID anyway and here’s your IOPS.
So I’m going to go ahead and hit save. If we scroll down here and have a look at capacity, we can see whether or not we want to do load balancing. So I’m going to go in here and I do want a load balance environment. I want a minimum of two instances and a maximum of four availability zones. You can say any one, any two, any three, or any I’m just going to leave it as any. In here we’ve got our scaling triggers. Now this is something interesting to watch. So in here we can change it to CPU utilization. We can do it based on an average and then the unit instead of bytes. That’s not really going to work with CPU utilization. We want to do it on the basis of percent. So we can do it for a period of five minutes between metric evaluations. If it goes at a particular percentage for more than five minutes, that’s when we’ll trigger auto scaling. So our upper threshold could be 90% and our lower threshold could be 15%. Do something like that. Go ahead and hit save. So that configures. All our auto scaling load balances are in here. I’m just going to do it on a port 80 because I don’t have an SSL certificate for this site yet. So your elastic load balancer is listening on.
Port 80 is the Http protocol and then you could obviously turn on Https, but because I don’t have an SSL certificate, I’m just going to leave it off cross zone load balancing. So you can say enable load balancing across multiple az’s. We definitely want to leave that on. And then connection draining is just basically the maximum time that the load balancer maintains connection to an Amazon EC two instance before forcibly closing the connection. So I’m going to say 20 seconds. Go ahead and hit save. Rolling updates and Deployments now this is actually really interesting and an important point for this exam. And if you are going to go on and do the DevOps Pro exam, this is a huge part of DevOps Pro and actually Elastic Beanstalk features quite heavily in DevOps Pro.
If you don’t know Elastic Beanstalk inside out doing DevOps Pro, you’re not going to pass. So here we’ve got our deployment policy. So when we do an update to our app, how do we want to deploy this update? Do we want to do it all at once? Do we want to do it as a rolling update? So if we do it a rolling update, we’re going to basically update either 30% of the fleet at all time or we can do it fixed. So we could do one instance at a time, two instances at a time, et cetera. You can do rolling with additional batch and then you can do immutable as well. And if you want to know what immutable is, you can click on the Learn More and we just scroll down. It says Immutable deployments. Perform an Immutable update to launch a full set of new instances running the new version of the application in a separate auto scaling group alongside the instances running the old version. So you’re not actually updating EC two instances, you’re creating a whole new environment in a separate auto scaling group. And that’s what an Immutable deployment is as well.
Coming back. So I’m going to switch this back over to just do it all at once. So Configuration updates is actually changes to your virtual machines and VPC configurations. So not changes to your application, but actually changes to your environment. Again, you can do rolling based on health, rolling based on time Immutable. None of this will really come up in the Developer Associate Exam. It will come up in the DevOps Pro Exam. However and down here we can customize our health checks. So we can say ignore health check, or we can customize it further. So I’m going to go ahead and hit Save. Let’s move down to security. So in here, security is pretty basic. It’s just what roles we’re going to use for this Elastic Beanstalk deployment. By default, we want to create a new role. And in here we’ve got our EC two key pairs. So you can choose which key pair you want. I’m going to go ahead and just use my Irish key, and that’s what I would use to log into my EC Two instance.
You can choose any key pair that you want. There monitoring in here we’ve got our Health Check path, so it might just be index PHP. You can either have the enhanced or basic monitoring notifications this will give you. You just enter in your email address there and you’ll get email notifications for important events around your environments. Basically just setting up an SNS topic network. Down here you can configure things like your own custom VPCs, so you can go in and choose your own VPC. You can also change the load, balancer settings, et cetera. Again, it’s pretty much outside the scope of the Developer Associate Exam and Databases. Now this is actually really interesting. So you can either have Elastic Beanstalk provision your database for you, or as Amazon recommend you, provision your own RDS instance and then connect it to Elastic Beanstalk.
Now the key difference between the two is if Elastic Beanstalk provisions your database, when you go in and delete your Elastic Beanstalk application, that’s going to go ahead and delete the database as well. If you don’t want that to happen, what you would do is go into RDS, create your own, let’s say, MySQL database, and then get Elastic Beanstalk to connect to. That when you’re creating your new Elastic Beanstalk application. And that means when you delete your Elastic Beanstalk application, your database won’t be deleted. And that is a really important exam topic. So you can click in here right now. I don’t think I have any RDS instances available inside my Irish one. So I could do MySQL we’ll do DB, one T, one micro, five gigs, enter the username as a cloud guru.
A cloud guru. And I’m just going to keep it as availability low. So one availability or one AZ. You could do multi az’s, et cetera. Now I am actually just going to hit cancel on this. I don’t really want to attach a database for this example just because it can cause much longer deployment times. So I’m going to hit cancel on that. We’re now ready to go ahead and create our app. So go ahead and hit Create app. Now I personally am getting this really weird error. It says no application version name, sample application found. If I go back previous, you can see in here that I’m clicking on an application code sample application. So what I might do is just come back out of this. This is why I hate elastic beanstalk. It could be real pain in the butt sometimes. So I’ll call it my Ryan application, something like that. Give it a new name, go ahead and hit Create and then it says no environments currently exist for this application. Create one. Now going to do a web server environment. You can also do worker environments. This comes up in the DevOps pro. A worker environment is basically something that where an application that processes long running workloads on demand or performs tasks on a schedule. So in a worker environment, each instance runs a demon process that reads messages from an Amazon SQS queue, then relays the contents of the message in a post request to the path that you configure. We don’t want this at the moment. We’re just going to do a very basic one.
So we’ll do a web server environment, go ahead and hit select and then we can put in here our domain. So let’s do my Ryan’s application, elastic Beanstalk and check the availability, make sure it’s actually available in here. I’m going to use a pre configured platform, just going to do PHP and then I’m going to go ahead and use the sample application and then I’m going to go ahead and hit Create environment and that I’m not going to go in and configure more options because I don’t want to break anything. I want this lab to actually work. So this will be provisioning our environment. Now it’s going to take a couple of minutes, but because we haven’t provisioned things like RDS instances in this particular one, it should be a lot quicker than doing it normally.
So I’m just going to pause the video here. We can see here it successfully launched the environment and it took basically 24 seconds to initialize or 24 seconds in two minutes if you open this up in a new tab or already drop me into the new splash screen. So here is the dashboard. So here we can see that the environment is healthy, it’s been deployed, it’s using the sample application. Here’s the configuration. I can go in here and change the configuration if I want to. We can open this up in a new tab. And there we go. It says, congratulations, your AWS elastic beatstart PHP application is now running on your own dedicated environment in the AWS cloud. You’re running PHP version 7. 0 21. Your version might be different depending on when you did this. So we can go in here and change the configurations here. We can start doing auto scaling, we can change our instance types, we can change our notifications. Basically everything we just went through, we can now change after this environment has been deployed live. If we actually go back over to the EC two console, we should be able to see this EC two instance. And here it is, it’s running in here.
And if we actually go through and check the tags, we can see that, the tags that it’s inherited. So its name is my ryan application environment. Then it’s got a whole bunch of other tags that elastic beanstalk have created automatically, because I didn’t go through with that customized setup that we spent the last sort of 1015 minutes looking at, and ended up hitting cancel on it. That’s why we don’t see those tags there. So like our tag for department marketing, et cetera, but you can add those back in. So just go back to elastic beanstalk. So in here we can see my environments. In here, this is the environment that I terminated earlier. And go ahead and feel free just to look at the logs, look at the health checks, monitoring, alarms, you can configure all this. The key takeaway for this though, really is going into the exam, you’re going to need to understand what the different configurations are.
So PHP, what the different languages are, essentially PHP net with IIS, et cetera, et cetera. You’re also going to need to understand that you can do both application updates as well as configuration updates. These can be rolling, you can do these all at once, you can do them an instance at a time, you can do them by a percentage, et cetera. The other thing you need to really have a good understanding of is that so this elastic beanstalk has gone in and provisioned just a single EC two instance here. If we were using autoscaling, it would have done a load balancer and multiple EC two instances, et cetera. Elastic beanstalk, the service itself is free, but the resources that it provisions on your behalf, you pay for. So that’s a really important point going into the exam.
Okay, so let’s quickly just click on all applications, select your application that you just created, and hit delete application. That will then delete both the application and all the resources that it has just provisioned. Now let’s look at my exam tips. So run through these really really quickly. What are my exam tips going into the exam? Well, you can have multiple versions of your application and your applications can be split into tiers. So you could have one application for your web tier, one for your application tier, one for your database tier and you can update your applications directly. You can also update the configuration of your application.
So you could change the EC two instance types, you could change the availability zones, the auto scaling, et cetera. Updates, whether it’s across your application or your configuration, can be applied at either one instance at a time or at percentages of instances. So maybe at the 30% of the fleet. Or you can do an Immutable update which is where it’s going to create an entirely new set of EC two instances, push the application update to those and then when it’s successfully launched, it will get rid of the other EC two instances. You can you do pay for the resources that you use, but Elastic Beanstalk is free. That is critical to know going into the exam. If Elastic Beanstalk creates your RDS database, then when you delete the application, it’s going to delete the RDS database as well. If you didn’t create the RDS database with your application, if you create your RDS database outside of Elastic Beanstalk, then when you delete the Elastic Beanstalk application, your RDS instance is going to stay there. Also know what languages are supported and so this is really crucial.
So Apache Tomcat for Java applications, apache Http server for PHP applications, apache http server python so basically Java, PHP, Python you can have NGINX or Apache for NodeJS, you can have Passenger or Puma for Ruby applications, you can have Microsoft IIS and 7. 58. 0 and 8. 5 for your net applications, you can have Java Se. It also supports Docker as well and also Go. So that’s it for this lecture guys. Hopefully you are able to follow along with that. Elastic Beanstalk can definitely be worth four or five questions in the exam, but just remember the exam tips at the end and you should be fine for those questions. In the next section we’re going to look at cloud formation. Cloud formation is far more powerful than Elastic Beanstalk and pretty much all the professional solutions architects in the world use it. So if you’ve got the time, please join me in the next lecture. Thank you.
5. Exam Preparation – Domain 4 Hey everyone and welcome back. In today’s video we will be discussing about the important pointers for exams for domain four. So the first thing here is that you should know about tagging strategies, about resource groups, about the EC to pricing models here then the overview about S… Read More »
4. Exam Preparation – Domain 3 Hey everyone and welcome back. Now in today’s video for important pointers for exams our focus would be on domain three. So the domain three is migration planning and it constitutes to be 15% of the examination. So let’s get started and see what are some of the important… Read More »
3. Exam Preparation Part 02 – Domain 2 Hey everyone, and welcome back. Now, in today’s video, we will be continuing our journey, understanding some of the important pointers for exams for domain two. As we have discussed, even in the earlier video, be aware about the distinction on which use cases where DynamoDB would… Read More »
2. Exam Preparation Part 01 – Domain 2 Hey everyone and welcome back in today’s video for important pointers. For exam, our focus would be on domain two. Now the domain two, which is designed for new solutions is one of the largest domains of this certification both in terms of the number of topics… Read More »
1. Exam Preparation – Domain 1 Hey everyone and welcome back. Now in today’s video we will be discussing about some of the important pointers for exam as far as the domain one is concerned. Now the domain one is basically designed for organizational complexity and it constitutes to be twelve 5% of the overall… Read More »
69. Building the function for our API Hey everyone and welcome back. Now in the earlier lecture we discussed that there are two important components that we need. The first is the function and second is the API. So what we’ll be doing today is we will be creating a function after function is created.… Read More »