Choosing an RDS Engine0:00
So far we have used multiple AWS services to get our serverless Laravel application up and running. Now let's talk databases. AWS offers a service called RDS. We can use it to manage databases without having to maintain any servers ourselves. It supports many database engines like MariaDB, MySQL, and PostgreSQL. And AWS also offers its own database engine that is compatible with MySQL and PostgreSQL. They call it Aurora. They advertise it with up to 5 times the throughput of MySQL and 3 times the throughput of PostgreSQL. And Aurora also comes with a full serverless database solution. So let's take a look at all our options here. Let's open the AWS console and head over to the RDS dashboard. Click on databases and then click on create database. The console will show us the database creation wizard. So let's scroll down a bit and we can see that we can select from several engine options. We have Amazon Aurora, MySQL, MariaDB, PostgreSQL, Oracle, and SQL Server. Let's choose MySQL like the normal MySQL. And we can see all the supported engine versions in the drop down menu. It supports MySQL 8 and MySQL 5.7. Now let's check Amazon Aurora. And we can see there are two editions, one that supports MySQL and one that supports PostgreSQL.
Connecting RDS to Weber5:49
If we click on the card, we will get redirected to the database details screen. And in this screen, we can check the database password in case we lost it. And then if we scroll down a bit, we can see that we can manage database users from this screen. We can also manage alarms to notify us if of unexpected spikes in connections and CPU utilization. And we can also check current database metrics like maximum number of connections, average number of connections and average CPU utilization. And if we scroll down, we can see even more metrics and more graphs. Now to attach this database to a Weber environment, let's head over to the weber.yaml file and add a database attribute and then provide the name of our database Laracasts. Now let's deploy. And behind the scenes, Weber will make sure to inject the database credentials into the standard Laravel environment variables so that the different functions can connect to the database. And to verify this, let's wait until the deployment completes. I fast forward this part using my video editing skills. And here we go. Now let's head over to the AWS console, click on one of our staging environment functions, click on versions, choose the latest version, scroll down and click on environment variables. Let's scroll down again and we can see that Weber has injected the database environment variables. Here is the connection, database name, host, password and username. Perfect. So there is more to talk about when it comes to using databases with Lambda functions, but that's for another lesson. Take care.
