In the previous tutorial, we have successfully created a Laravel application and deployed into AWS using Elastic Beanstalk. In this tutorial, we will show you the step by step of how to configure the Laravel application with MySQL using AWS Elastic Beanstalk and RDS.
Go to the Elastic Beanstalk, navigate to the Configuration on the left-hand side. In the Database category, click Modify button.
Ensure you choose MySQL on Engine selection. Fill up username and password, then click Apply button.
Go back to AWS Management Console, select RDS, click on DB instances to view the created database details. You will see one of DB instance has been created successfully.
Next, click on the DB identifier to view the configuration details. Copy down the endpoint, this will be the hostname.
Finally, navigate to the Configuration tab, copy down the dbname and username.
Now, you have done created a database called “ebdb”.
Connect MySQL to your Laravel project
Now, we are ready to connect the database to the Laravel project. Go back to Elastic Beanstalk and navigate to Configuration, under Software category click Modify button. Scroll down to the Environment properties section, fill up the database properties as below. These properties will override the value in the .env environments file.
Congratulation, you have successfully hosted a Laravel project on AWS cloud.