Configuration: Setting Up User Data

Now that our WordPress image is able to read environment variables to set up its configuration, it’s time to provide them.

Note: For now, you will create the environment variables and the credentials in the EC2 user data script. This is not ideal for security and flexibility reasons, but right now, you haven’t learned about other ways to do so yet. In any case, the fundamental approach of using environment variables is good, just hardcoding the credentials into the EC2 user data is not. Later on in this course, you’ll learn about AWS Parameter Store meant to store credentials more securely.

Extracting your DB_PASSWORD

Run the script in the code widget below to extract your DB_PASSWORD. All it does is log setting up your SSH key, get the public DNS name, and then execute the grep DB_PASSWORD /opt/bitnami/wordpress/wp-config.php command to print out all lines in the wp-config.php file that contain DB_PASSWORD.

Get hands-on with 1200+ tech skills courses.