There are two options here and it really depends on the nature of the relationship between the applications and why they need to be deployed sequentially.
1. If your applications are fairly independent
The best way to do this is to create a new AWS CodeDeploy Application for each of your applications. Each application will have its own AWS CodeDeploy Deployment Group - however, all the deployment groups can point to the same autoscaling group (or tag configuration if that is how you're identifying it). So although they look like separate deployment groups (because they are nested inside each separate application) they are actually describing the same set of servers.
The structure will look like:
- Application 1
- Application 2
If you want to ensure the applications deploy sequentially, it is then up to you manage that when using the API to push a new revision. We typically script it to push the revision, then periodically poll the api for the status of the created deployment until it is complete (or if you're using the AWS CLI you can use aws deploy wait deployment-successful
), and then proceed to the next application.
This structure gives you the flexibility to deploy updates to a single application without having to touch the others.
It will also mean that each application will completely deploy (i.e. be started and operational) before the next application starts deployment.
2. If your applications are tightly coupled
You might be better of bundling all the applications together into a single AWS CodeDeploy Application and using the script associated with the AfterInstall
hook to sequentially configure and 'turn on' each application (e.g. start service/daemon). Further details on how to do that will depend on the nature of your applications, and potentially on the reason behind why you need to deploy these applications sequentially.
This gives you the flexibility to sequentially execute configuration logic and defer 'starting' the applications until you are sure all applications are successfully copied and configured.
Edit 20170606 - Remove Approach 1
While the original question only relates to a single instance, not an ASG, I'm removing approach 1 as it is technically incorrect.
If you really do want multiple applications on the same instance, it seems best practice these days is to bundle them into the same CodeDeploy Application.