Version Control & Auto-Deploy your Files Stored in Amazon EFS

Although the primary use case of Amazon EFS is to be used as an NFS, occasionally it could hold the kind of data that lends well to version control. A WordPress installation is one such example. And where there is version control, automated deployment pipelines aren’t far behind. This article describes a way for you to automatically deploy files from a CodeCommit repository to an EFS file system, whenever a change is pushed to the repo. We do this by creating a pipeline as shown below:

Skip the deploy stage & create the pipeline. The build spec is where you put commands to copy everything from the CodeCommit repo to the EFS mount point inside the CodeBuild instance. The env var CODEBUILD_SRC_DIR in CodeBuild holds the location of the contents of the CodeCommit repo. All you have to do is copy this to the EFS using a command like cp -Rf $CODEBUILD_SRC_DIR/ /my-efs/.