Codedeploy

CodeDeploy can be used to deploy code to EC2 instance of on-premise server.

Usage

Code Origins

Setup

Process

CodeDeploy only do the deployment, do not provision resource

Blue/green deployments are only available for the EC2 Instances not the on-premise servers

When need to deploy in multiple environments, need to create multiple codeDeploy group

AppSpec

With appspec.yml, we define how we get the codebase and deploy it.

In the File Section we define the source like s3 or github.

Then, have a sequence of following hooks and we can define our actions in these hook,

  1. Application Stop: Stopping the existing version of app
  2. DownloadBundle: Get/download the new codebase
  3. BeforeInstall: Task to do before installing the new app
  4. AfterInstall: Task to do after installing the app
  5. ApplicationStart: Task to start the new app
  6. ValidateService: A health check to determine if the app is running properly

All hooks are,

ApplicationStop -> DownloadBundle -> BeforeInstall -> Install -> AfterInstall -> ApplicationStart -> ValidateService -> BeforeAllowTraffic -> AllowTraffic -> AfterAllowTraffic

Types Of Deployment

Blue green deployment is not supported by on premise servers

Get Secure Parameters In CodeDeploy from Parameter Store

Rollback When Missing Files

During rollback, if the existing files are removed or no permissions,