Yanyan Ni
Yanyan Ni

Reputation: 223

How can I deploy multiple applications to a instance using AWS codedeploy

I'm a new to codedeploy, I plan to deploy multiple applications in order to a single instance. I'm using cloudformation template to create codedeploy, and couldn't find any instruction for deploy multiple application revisions. Here is what I want to do:

  1. I want to deploy the applications using same codedeploy group, each application source file located in same S3 bucket with different file name.
  2. I want to sequentially deploy these applications. Can I use cloudformation template to do that?

Upvotes: 7

Views: 6350

Answers (3)

Mss
Mss

Reputation: 3

Create separate CodeDeploy applications for each repository. Each application will correspond to a different repository.

Then create deployment groups. Within each CodeDeploy application, create a deployment group that targets the same instance. Ensure that the deployment groups from different applications do not conflict with each other.

Upvotes: 0

Chris Simon
Chris Simon

Reputation: 6505

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
    • DeploymentGroup1
      • ASG-abc
  • Application 2
    • DeploymentGroup2
      • ASG-abc

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.

Upvotes: 3

Nitin AB
Nitin AB

Reputation: 538

Associating multiple deployment groups to same ASG is not recommended by AWS, http://docs.aws.amazon.com/codedeploy/latest/userguide/auto-scaling-integ.html

Upvotes: 4

Related Questions