Search code examples
node.jsamazon-web-servicescontinuous-deploymentaws-code-deploy

How to explain to AWS CodeDeploy how to deploy my NodeJS application?


I'm sorry in advance for asking this question, AWS has countless tutorials (and much blogs tackle AWS in general), but I can't put my hand on a simple tutorial on how to explain to CodeDeploy how to deploy my code.

I'm fairly confident that I understand the basics of EC2, Auto-scaling groups & CodeDeploy, but what I can't find is how to explain to CodeDeploy how to deploy my app. When I use CodeDeploy, I click on a button 'Deploy', but how come CodeDeploy knows what to do?

In order to deploy effectively, CodeDeploy would need to :

  • Pull the source
  • Run npm install
  • Run npm start

Nothing fancy, but still, I don't know where to explain that. My guess is that there's some configuration file somewhere in the project (most likely in yaml format) to specify those intructions but I find no tutorial clearly explaining such thing.

Just to be clear, I don't want to :

  • Manually connect to my instance to do such instructions, I need them to be automatic
  • Use config files to specify architecture params (I use the console for that purpose). I just want to explain how to run my app.

Any help would be welcome, and if I'm completely mistaken on how to do such things, please do not hesitate to point me to the right direction!


Solution

  • My guess is that there's some configuration file

    Yes, that's correct. When you deploy your app, CD will look for appspec.yml which contains all the build and setup instructions for your app on the instances.

    So you have to create such a file tailored to your use-case. AWS docs have example for that.