AWS CodeDeployment issue
Yesterday I've struggle to deal with this error message
[root@ip-10-0-0-123 state]# /opt/codedeploy-agent/bin/codedeploy-local --bundle-location s3://my-codedeploy/my_project.zip --type zip
Starting to execute deployment from within folder /opt/codedeploy-agent/deployment-root/default-local-deployment-group/d-8LAE2X2CH-local
See the deployment log at /opt/codedeploy-agent/deployment-root/default-local-deployment-group/d-8LAE2X2CH-local/logs/scripts.log for more details
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:223:in `parse_app_spec': The CodeDeploy agent did not find an AppSpec file within the unpacked revision directory at revision-relative path "appspec.yml". The revision was unpacked to directory "/opt/codedeploy-agent/deployment-root/default-local-deployment-group/d-991ZCTCHC-local/deployment-archive", and the AppSpec file was expected but not found at path "/opt/codedeploy-agent/deployment-root/default-local-deployment-group/d-991ZCTCHC-local/deployment-archive/appspec.yml". Consult the AWS CodeDeploy Appspec documentation for more information at http://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file.html (RuntimeError)
        from /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:101:in `initialize'
        from /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:147:in `new'
        from /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:147:in `block (3 levels) in map'
        from /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:146:in `each'
        from /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:146:in `block (2 levels) in map'
        from /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:68:in `execute_command'
        from /opt/codedeploy-agent/lib/aws/codedeploy/local/deployer.rb:85:in `block in execute_events'
        from /opt/codedeploy-agent/lib/aws/codedeploy/local/deployer.rb:84:in `each'
        from /opt/codedeploy-agent/lib/aws/codedeploy/local/deployer.rb:84:in `execute_events'
        from /opt/codedeploy-agent/bin/codedeploy-local:125:in `<main>'

Diagnostics

- Various source said I've misconfigured the security group settings. Which is not the case.
- The zip file was fine in S3 but the deployment agent doesn't seem to extract the zip file.
- After hours of digging into the ruby code. I've found that it doesn't even download the bundle yet. ( that it had not step into the download_bundle function in command_executor )
- It try to run BeforeBlockTraffic before downloading the bundle. Which is kind of a hint.

Summary

Turns out that I've mistakenly removed the previous deployment files. It tried to run the BeforeBlockTraffic in the previous deployment ( which make sense ). To fix this I just remove all the files under /opt/codedeploy-agent/deployment-root/. So there is no previous deployment record to be found.

Welp, this seems stupid but at least I've learnt some ruby code today.
Tag(s): CodeDeploy AWS
Profile picture
斟酌 鵬兄
Mon Jun 10 2019 04:57:43 GMT+0000 (Coordinated Universal Time)
Last modified: Mon Jun 10 2019 05:10:11 GMT+0000 (Coordinated Universal Time)
Comments
No comments here.
Do you even comment?
website: 
Not a valid website
Invalid email format
Please enter your email
*Name: 
Please enter a name
Submit
抱歉,Google Recaptcha 服務被牆掉了,所以不能回覆了