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

3

7

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?
Carrasquillo answered 16/8, 2016 at 16:15 Comment(0)
M
4

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

Mardellmarden answered 6/10, 2016 at 10:57 Comment(1)
The question does not relate to ASGs - it specifically relates to a single instance, which can be done using a tag-based deployment groupPandanus
P
3

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.

Pandanus answered 17/8, 2016 at 6:18 Comment(5)
Considering the answer provided by @nitin-ab and the Amazon recomendation, does the solution 1 solves this issue? Or in other words, Amazon recommends that you don't associating multiple deployment groups to same ASG, but this is not what you propose on solution one, can we associating multiple applications to same ASG?Endicott
Unfortunately approach #1 does not work. I get exactly the same error as I do when I use different deployment groups pointing to the same instance: Multiple deployments are attempting to run at the same time on an instance;Endicott
how do you deal with autoscaling with approach #1? When a new instance is added all application deploys are launched at the same time...Endicott
@Endicott - applogies, looks like approach 1 was a red herring. Not sure if AWS has changed this behaviour recently or if I was just mistaken at the time. Either way, it's not accurate, so have edited the answer. Even if you have two independent applications, recommend bundling them into the same CodeDeploy Application if you want them to be deployed to the same ASG.Pandanus
thank you for replying. The main problem we face is with autoscaling, where the deploys are launched all at once, and this is what causes the issues. As you can imagine this happens when you most need that extra instance ;)Endicott
A
0

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.

Artilleryman answered 20/6 at 8:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.