AWS CodeDeploy Application Specification Files
An application specification file (AppSpec file), which is unique to AWS CodeDeploy, is a YAML-formatted file used to:
Map the source files in your application revision to their destinations on the instance.
Specify custom permissions for deployed files.
Specify scripts to be run on each instance at various stages of the deployment process.
The AppSpec file is used to manage each deployment as a series of lifecycle events. Lifecycle event hooks, which are defined in the file, allow you to run scripts on an instance after many of the individual deployment lifecycle events. AWS CodeDeploy runs only those scripts specified in the file, but those scripts can call other scripts on the instance. You can run any type of script as long as it is supported by the operating system running on the instances.
For information about how to create a well-formed AppSpec file, see AppSpec File Reference.
How the AWS CodeDeploy Agent Uses the AppSpec File
During deployment, the AWS CodeDeploy agent looks up the name of the current event in the hooks section of the AppSpec file. If the event is not found, the AWS CodeDeploy agent moves on to the next step. If the event is found, the AWS CodeDeploy agent retrieves the list of scripts to execute. The scripts are run sequentially, in the order in which they appear in the file. The status of each script is logged in the AWS CodeDeploy agent log file on the instance.
If a script runs successfully, it returns an exit code of 0 (zero).
For information about AWS CodeDeploy agent log files, see Working with the AWS CodeDeploy Agent.
During the Install event, the AWS CodeDeploy agent uses the mappings defined in the files section of the AppSpec file to determine which folders or files to copy from the revision to the instance.
If the AWS CodeDeploy agent installed on the operating system doesn't match what's listed in the AppSpec file, the deployment will fail.