An AppSpec file is a configuration file that specifies the files to be copied and scripts to be executed. The AppSpec file uses the YAML format, and you include it in the root directory of your revision. The AppSpec file is used by the AWS CodeDeploy Agent and consists of two sections. The files section specifies the source files in your revision to be copied and the destination folder on each instance. The hooks section specifies the location (as relative paths starting from the root of the revision bundle) of the scripts to run during each phase of the deployment. Each phase of a deployment is called a deployment lifecycle event. The following is a sample AppSpec file. For more information on an AppSpec file, including all the options that can be specified, see AppSpec File Reference.
os: linux
files:
# You can specify one or more mappings in the files section.
- source: /
destination: /var/www/html/WordPress
hooks:
# The lifecycle hooks sections allows you to specify deployment scripts.
ApplicationStop:
# Step 1: Stop Apache and MySQL if running.
- location: helper_scripts/stop_server.sh
BeforeInstall:
# Step 2: Install Apache and MySQL.
# You can specify one or more scripts per deployment lifecycle event.
- location: deploy_hooks/puppet-apply-apache.sh
- location: deploy_hooks/puppet-apply-mysql.sh
AfterInstall:
# Step 3: Set permissions.
- location: deploy_hooks /change_permissions.sh
timeout: 30
runas: root
# Step 4: Start the server.
- location: helper_scripts/start_server.sh
timeout: 30
runas: root