Mounting the EFS File System
Learn to modify the WordPress instance to mount the EFS file system.
The EFS file system is set up now, but we still need to move the data and tell our WordPress instance how to use it. To move the data, we need to mount the EFS file system and copy the content of the wp-content
folder to the EFS file system.
Moving the data
Let’s follow the steps below to move the data.
Step 1: Get EFS file system ID
We will need the EFS file system ID in a later step, so it’s a good idea to retrieve it now. Later, we’ll be logged in via SSH and won’t be able to easily access it
To get the EFS file system ID, we can use the describe-file-systems
command that we already used in the last lesson:
aws efs describe-file-systems \--query "FileSystems[?Name=='wordpress-efs']".FileSystemId \--output text
Run it in the terminal below:
The output should be similar to this (starting with fs-
) but display a different ID:
fs-044c22ac078984d92
Please copy the file system ID and modify the EFS_FILESYSTEM_ID
environment variable in the Educative terminal above to save it.
Step 2: Starting a WordPress instance
To start a WordPress instance, we can use the run-instances
command and pass the launch template name.
In this case, we will also add a new tag, Name=wordpress-efs-instance
, to be able to refer to this specific instance later on.
Therefore, the full command looks like this:
aws ec2 run-instances \--launch-template 'LaunchTemplateName=custom-wordpress-vpc' \--tag-specification 'ResourceType=instance,Tags=[{Key=Name,Value=wordpress-efs-instance}]' \--query 'Instances[*].InstanceId' \--output text
Run it in the terminal below:
The output should be just the instance ID, for example: ...