- Products›
- Amazon CodeDeploy
Amazon CodeDeploy FAQs
General
Open allConcepts
Open allA deployment group is a set of instances associated with an application that you target for a deployment. You can add instances to a deployment group by specifying a tag, an Auto Scaling group name, or both. You can define multiple deployment groups for an application such as staging and production. For information on tags, see Working with Amazon EC2 Tags in the Console. For more information on deploying to Auto Scaling groups, see Auto Scaling Integration.
A deployment configuration is a constraint that determines how a deployment progresses through the instances in a deployment group. You can use a deployment configuration to perform zero-downtime deployments to multi-instance deployment groups. For example, if your application needs at least 50% of the instances in a deployment group to be up and serving traffic, you can specify that in your deployment configuration so that a deployment does not cause downtime. If no deployment configuration is associated with either the deployment or the deployment group, then by default Amazon CodeDeploy will deploy to one instance at a time. For more information on deployment configuration, see Instance Health.
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 Amazon 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.
version: 0.0
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
| Deployment Lifecycle Event | Description |
| ApplicationStop | This is the first deployment lifecycle event that occurs even before the revision gets downloaded. The AppSpec file and scripts used for this deployment lifecycle event are from the last successfully deployed revision. You can use the ApplicationStop deployment lifecycle event if you want to gracefully stop the application or remove currently installed packages in preparation of a deployment. |
| DownloadBundle | During this deployment lifecycle event, the agent copies the revision files to a temporary location on the instance. This deployment lifecycle event is reserved for the agent and cannot be used to run user scripts. |
| BeforeInstall | You can use the BeforeInstall deployment lifecycle event for preinstall tasks such as decrypting files and creating a backup of the current version. |
| Install | During this deployment lifecycle event, the agent copies the revision files from the temporary location to the final destination folder. This deployment lifecycle event is reserved for the agent and cannot be used to run user scripts. |
| AfterInstall | You can use the AfterInstall deployment lifecycle event for tasks such as configuring your application or changing file permissions. |
| ApplicationStart | You typically use the ApplicationStart deployment lifecycle event to restart services that were stopped during ApplicationStop. |
| ValidateService | ValidateService is the last deployment lifecycle event and is an opportunity to verify that the deployment completed successfully. |
Getting started
Open allUsing Amazon CodeDeploy
Open allThe following diagram shows the typical steps during a deployment. Creating an application and deployment group (see the Concepts section for an explanation of these terms) are typically one-time setup tasks per application. The recurring actions are uploading a revision and deploying it. For a detailed explanation, including step-by-step instructions for each of these tasks, see Deployments.
You can access Amazon CodeDeploy using the Amazon Web Services Management Console, the Amazon SDKs, and the Amazon CodeDeploy APIs.
You can track the status of a deployment using the Amazon Web Services Management Console, the Amazon SDKs, and the Amazon CodeDeploy APIs.You can see the overall status of a deployment and drill down further to see the status of each instance and the status of each deployment lifecycle event for the instance. You can also see the log entries corresponding to any failure, making it easy to debug deployment issues without having to log into the instance.