‫So now let's have a look
‫at the deployment of app updates.
‫So for this, let's go under configuration
‫on the left hand side,
‫and then we are in the prod environment.
‫We scroll down
‫and we are looking for updates, monitoring, and logging.
‫So we click on edit.
‫And underneath we have at some points,
‫rolling updates and deployments.
‫So we have the application deployments,
‫which is, okay, we deploy a new application version.
‫What is going to happen and how is it going to be deployed?
‫So here we have a couple of deployment policy.
‫We have all at once,
‫and all at once just gives your code update
‫to all the instances at one,
‫you will be down, but it will be the fastest.
‫As you can see, you can choose between fixed and percentage,
‫but actually these are disabled.
‫So these settings do not matter for all at once.
‫They're just remained within the UI for some reason.
‫For rolling, then these settings become available.
‫So we take down some instances, we upgrade them,
‫and then we go and move on.
‫So the batch size could be either a percentage,
‫for example, 30% of instances at a time
‫or fixed, for example, one instance at a time.
‫So this is one option.
‫Rolling with additional batch will add EC2 instances,
‫will deploy to those and then we'll keep on having a batch.
‫So we make sure that we maintain the same capacity
‫no matter what, but there is an increased cost,
‫because we are creating temporarily some EC2 instances
‫to perform this update.
‫And again, we can set up a percentage or a fixed.
‫Then we have immutable.
‫So immutable is creating a whole new set
‫of instances we deploy to,
‫and then we'll delete the old ones.
‫So that's what we'll be experimenting with.
‫And again, fixed and percentages don't make sense here,
‫so they're disabled sort of.
‫And then we have traffic splitting.
‫So to split traffic to a percentage
‫of new applications versions for X number of minutes
‫before upgrading everything.
‫So this is really cool.
‫Let's explore immutable.
‫Also, we have configuration updates.
‫So this is when you actually are updating
‫your EC2 instances internally
‫or making VPC configurations or whatever,
‫that should make your instances being replaced.
‫In that case, we can again choose a rolling
‫or immutable type of updates,
‫but the exam really doesn't test you on that part.
‫It tests you on the application deployment part.
‫So we'll explore immutable
‫and I will scroll down and I will apply this.
‫So now we apply some new configurations in our environments.
‫So anytime we do this,
‫Elastic Beanstalk is going to be updating the environment.
‫So in the meantime, let's go on Google
‫and type sample application nodejs Beanstalk.
‫And we are going to click on this, on those tutorials.
‫And then we're going to find the sample application
‫for Node.js.
‫So if we scroll down, Node.js is right here, nodejs.zip.
‫So you download the zip file and then you open it.
‫So here we have a couple of files
‫and we'll explore them in a second.
‫So this is how my application is packaged.
‫This is the Node.js specific part of the application.
‫Index of HTML is actually representing that welcome page.
‫So here we have couple of options.
‫We can set the style,
‫but we can also, for example, set the text,
‫for example, who says congratulations.
‫And then we have cron.yaml
‫which is to schedule some tasks if you wanted to.
‫This is to run some regular tasks
‫directly on our instances.
‫App.js, this is a Node.js part of it
‫where we actually create a server
‫and we're going to server the HTML content right here,
‫.gitignore we can ignore.
‫And then .ebextension is a way to customize
‫the way that Elastic Beanstalk is working
‫by creating configurations within that .ebextension,
‫.ebextensions directory.
‫So what we're going to do
‫is that we're going to change the background
‫from green to blue.
‫So the way we do it is that we find the right place.
‫So this is the one, background-color, textColumn,
‫and we're just going to enter blue.
‫So I can just click on blue right here,
‫or I can also, if this allows me to,
‫I can just type in blue
‫and it'll be good to go.
‫So whatever you wanna do, right?
‫But to set the background color,
‫and if you don't wanna do that,
‫I have packaged actually a zipped version of this,
‫because sometimes Elastic Beanstalk is not very happy
‫to how you zip thing.
‫I've packaged a zip version of your application
‫to use the blue background color.
‫So this is what I'm going to use in my course right now.
‫So let's go and deploy this new version.
‫So we're going to click on upload and deploy,
‫and then we have to choose an application file.
‫So under my code, find Elastic Beanstalk.
‫So under Beanstalk and then there is nodejs-v2-blue.zip
‫and we can have a version label,
‫for example, I'll call this one MyApplication-Blue.
‫And here we have deployment preferences.
‫So by default it's set to immutable,
‫because that's what we have currently set up,
‫but you can override it if you wanted to
‫with other kind of deployments,
‫for example, all at once, rolling,
‫or rolling with additional batch.
‫But we wanna use immutable
‫so we'll just submit and deploy this as immutable.
‫So we'll have a look at how immutable is actually working.
‫And so the way it works is that,
‫and we have to see in the events
‫how it's going to happen.
‫So let's refresh this and have a look.
‫So it says launching one instance with the new settings
‫to verify health.
‫So first, it makes sure
‫that like we can actually deploy this version
‫and it is working.
‫And this is going to be done
‫by creating a new auto scaling group.
‫So let's wait for a moment.
‫Okay, so now a temporary auto scaling group has been created
‫and this auto scaling group will have the new instance,
‫and, of course, we're immutable,
‫so we have to launch a new auto scaling group
‫and new instances within.
‫So now the instance is created
‫and then we have a new instance added to the load balancer
‫and we're waiting for the instance to pass the health check,
‫which it did.
‫So now that the instance are initialized,
‫we are detaching the new instances
‫from the temporary auto scaling group,
‫and we attach them to the permanent auto scaling group.
‫And then there's post-deployment configuration
‫on new instances.
‫And then at the end of this,
‫the old instances will just go away,
‫and immutable will have been performed.
‫So the deployment is complete
‫and things that happen is that the instance was removed
‫from the environment,
‫and then the new application deploy version was deployed,
‫and then everything was terminated, the old instances,
‫and the temporary auto scaling group.
‫So we're good to go.
‫So now if we open this in a new tab,
‫as we can see, congratulations is in blue.
‫And so we have successfully deployed this version update
‫into our environments.
‫So now the prod is displaying blue
‫and the dev is displaying green.
‫And one thing we can experiment with
‫is environment swapping.
‫So we can swap environment domains.
‫That means that the prod will become dev
‫and the dev will become prod.
‫And the reason we would do so
‫is, for example, you take this environment,
‫for example, prod.
‫First, you're going to clone it.
‫So you're going to create a copy of prod,
‫then you would deploy your new application
‫to the new environment
‫where you can perform some extensive testing.
‫Call it prod number two.
‫And then once you want prod number two
‫to become prod number one,
‫you would swap environment domains
‫and then the URLs will be swapped.
‫So I'm going to demo the swap environment domain,
‫but using prod and dev.
‫So this is blue and then this is green,
‫but let's swap environment domains and see what happens.
‫So we are going to swap this with dev and click on swap.
‫So swap environment domain has to do with DNS
‫and entries, and they're going to be modified.
‫So that one is pointing to the other and vice versa.
‫So this may take a bit of time
‫to be updated and also to reflect the updates,
‫because DNS updates can be slow sometimes.
‫So I'm going to wait five more minutes and get back to you.
‫So my update is now done,
‫and if I go onto my prod environment and refresh,
‫I see now green.
‫And if I go to my green environment and refresh,
‫I see now blue.
‫So indeed the environments have been swapped,
‫and everything is working as expected
‫which is, I think, pretty cool.
‫So that's it for this lecture.
‫What I'm going to do is just re-swap the environment domains
‫just to have the blue as prod, and the green as dev,
‫but we're good to go.
‫So we've seen all the deployment options.
‫We've seen about cloning, we've seen swapping URLs,
‫and I hope you liked it.
‫I will see you in the next lecture.