Update Launch Template to Use RDS Database
Learn to update the EC2 user data to use the RDS endpoint.
Now that we know everything is working, we just need to make these changes permanent and integrate them into our launch template.
To do so, we need to do the following:
- Update the
DB_HOST
environment variable in our EC2 user data of thecustom-wordpress-vpc
launch template. - Add commands to stop MariaDB running on the WordPress instance. We don’t need it anymore when we are using the RDS database.
- Create a new version of the
custom-wordpress-vpc
launch template. - Set this new version as the default version for the launch template.
Update EC2 user data
Updating the EC2 user data is relatively easy because we just need to replace localhost
in the DB_HOST
environment variable with the content of our RDS_ENDPOINT
environment variable, and then we add some extra commands to disable the MariaDB database running on the WordPress instance.
Let’s use a simple script for this. We already used most of the commands before, so it should be straightforward.
Get hands-on with 1400+ tech skills courses.