CodeDeploy - gpawade/gpawade.github.io GitHub Wiki

Files -

1. "/" for Amazon Linux, RHEL, and Ubuntu Server instances, or "\" for Windows Server instances.

Environment Variable Availability for Hooks

- APPLICATION_NAME 
The name of the application in AWS CodeDeploy that is part of the current deployment 
- DEPLOYMENT_ID
The ID AWS CodeDeploy has assigned to the current deployment (for example, d-AB1CDEF23).
- DEPLOYMENT_GROUP_NAME
- DEPLOYMENT_GROUP_ID
- LIFECYCLE_EVENT
The name of the current deployment lifecycle event (for example, AfterInstall)

Hooks -

1. ApplicationStop - This deployment lifecycle event occurs even before the application revision is downloaded.  
Note - 
An AppSpec file does not exist on an instance before you deploy to it. For this reason, the ApplicationStop hook will not run the first time you deploy to the instance. You can use the ApplicationStop hook the second time you deploy to an instance.


2. BeforeInstall- You can use this deployment lifecycle event for preinstall tasks, such as decrypting files and creating a backup of the current version. 

3. AfterInstall - You can use this deployment lifecycle event for tasks such as configuring your application or changing file permissions.

4. ApplicationStart-  You typically use this deployment lifecycle event to restart services that were stopped during ApplicationStop.

5. ValidateService – This is the last deployment lifecycle event. It is used to verify the deployment was completed successfully.

6. BeforeBlockTraffic – You can use this deployment lifecycle event to run tasks on instances before they are deregistered from a load balancer.

7. AfterBlockTraffic – You can use this deployment lifecycle event to run tasks on instances after they are deregistered from a load balancer.

8. BeforeAllowTraffic – You can use this deployment lifecycle event to run tasks on instances before they are registered with a load balancer.

9. AfterAllowTraffic – You can use this deployment lifecycle event to run tasks on instances after they are registered with a load balancer.

Sampel

version: 0.0
os: windows

files:
    - source : app/index.html
       destination: c:\sites\myapp

hooks:
    BeforeInstall:
        - location: beforeinstall.ps1
          timeout: 1000

AWS Cli

# Deployment
aws deploy create-deployment --application-name "PCI-HotelEngine" --deployment-group-name "uat" --description "Test deploymnet" --profile voyagercont --s3-location bucket=continuityreleases,bundleType=zip,key=ActivityEngine/ActivityEngine.5.35.9.zip --output text

# wait for deployment successfull
aws deploy wait deployment-successful --deployment-id "d-3TZNTYXIR" --profile voyagercont


aws deploy get-application --application-name "PCI-HotelEngine" --profile voyagercont


# Shell command for create deployment & wait
aws deploy wait deployment-successful  --profile voyagercont --deployment-id `aws deploy create-deployment --application-name "PCI-HotelEngine" --deployment-group-name "uat" --description "Test deploymnet" --profile voyagercont --s3-location bucket=continuityreleases,bundleType=zip,key=ActivityEngine/ActivityEngine.5.35.9.zip --output text`
⚠️ **GitHub.com Fallback** ⚠️