Provide AWS CodeDeploy with the package version number in deploy_to_ec2
Proposal
One of our customers is unable to perform rollback in case of failure during the deployment process, because the package S3 version is not available. This information is generated by the aws deploy push
command, but currently discarded (aws deploy push "${args[@]}" > /dev/null
, link).
So in order to overcome this situation, the customer suggested capturing the output of the aws deploy push
and store the details (version
, eTag
). Then pass these values to the deployment step (deploy_to_ec2
), ensuring CodeDeploy has them for rollback functionality.
Implementation guide
To resolve this issue, you will need to provide the "S3Location"::"Version" when you creates a deployment. ‘gl-ec2’ which is used to create deployment has function ‘push_to_s3’ which does not take the application revision version from output of "aws deploy push" command, instead it sends the output to /dev/null. Below is the snippet:
aws deploy push "${args[@]}" > /dev/null >>>>
PROBLEM HERE on line 73
To correct this, the function "push_to_s3()" should return the output of "aws deploy push” which produces the "Version". You can then use the version and the eTag values to pass to the ‘deploy_to_ec2’ function at line 25. It looks like this line may not have to change if ${args[@]}
is properly formatted.