Saving Your State

Learn to use AMIs and launch templates to package our deployment.

In the last lesson, we set up the configuration of our WordPress instance such that we can pass the DB_* parameters from the outside via the EC2 user data. But right now, we’ve only applied this to one instance, and it isn’t reusable.

Using AMIs to save state

To make it reusable and reproducible, we’ll learn to create an AMI from the instance and how to reuse this AMI to recreate the modified WordPress instance in a reproducible way. Afterward, we will see how we can create a launch template with this new AMI to recreate our WordPress instance with one CLI command (or a few clicks on the AWS Console).

Because we haven’t terminated the instance in the last lesson, it should still be running and accessible.

Before we create the AMI, we once again need to reset the cloud-init files and stop the instance, so run the script below:

Get hands-on with 1200+ tech skills courses.