I've been running deployments through CodeDeploy for a while, but a couple weeks ago, CodeDeploy started failing every deploy (all of which previously worked without issue) to one of my on-premise instances with the following error at BeforeInstall:
No such file or directory - C:\ProgramData/Amazon/CodeDeploy/02b29d0e-63b6-46b4-a7e4-ff7388bd510a/d-AJW81DA4U/deployment-archive/appspec.yml
If I check that directory afterwards, the file is clearly there and accessible. I have tried running the CodeDeploy Agent service both as an administrator account (which does have access to that file) and Local System (which, to my understanding, should have access to everything anyways).
The last mention of that deployment in CodeDeploy's log file (which includes debug-level logs) is the agent reporting the success of the DownloadBundle step.
I'm using Atlassian's Bamboo to call CodeDeploy and the same deployment succeeds to another on-premise instance (also a Windows machine), with identical configuration in Bamboo except for the deployment group.
Some of the time, instead of getting the above error CodeDeploy gives this error (also at BeforeInstall) and the deployment directory is empty (it doesn't even contain the downloaded bundle):
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 "C:\ProgramData/Amazon/CodeDeploy/02b29d0e-63b6-46b4-a7e4-ff7388bd510a/d-VEP5Z464U/deployment-archive", and the AppSpec file was expected but not found at path "C:\ProgramData/Amazon/CodeDeploy/02b29d0e-63b6-46b4-a7e4-ff7388bd510a/d-VEP5Z464U/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
In this case the log file shows the following error:
2018-07-06T10:13:37 ERROR [codedeploy-agent(8156)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Error during perform: RuntimeError - 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 "C:\ProgramData/Amazon/CodeDeploy/02b29d0e-63b6-46b4-a7e4-ff7388bd510a/d-VEP5Z464U/deployment-archive", and the AppSpec file was expected but not found at path "C:\ProgramData/Amazon/CodeDeploy/02b29d0e-63b6-46b4-a7e4-ff7388bd510a/d-VEP5Z464U/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 - C:/Windows/TEMP/ocr5F30.tmp/src/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:213:in
parse_app_spec' C:/Windows/TEMP/ocr5F30.tmp/src/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:100:in
initialize' C:/Windows/TEMP/ocr5F30.tmp/src/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:147:innew' C:/Windows/TEMP/ocr5F30.tmp/src/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:147:in
block (3 levels) in map' C:/Windows/TEMP/ocr5F30.tmp/src/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:146:ineach' C:/Windows/TEMP/ocr5F30.tmp/src/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:146:in
block (2 levels) in map' C:/Windows/TEMP/ocr5F30.tmp/src/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:68:inexecute_command' C:/Windows/TEMP/ocr5F30.tmp/src/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:114:in
process_command' C:/Windows/TEMP/ocr5F30.tmp/src/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:96:inacknowledge_and_process_command' C:/Windows/TEMP/ocr5F30.tmp/src/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:75:in
block in perform' C:/Windows/Temp/ocr5F30.tmp/gemhome/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:348:inrun_task' C:/Windows/Temp/ocr5F30.tmp/gemhome/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:337:in
block (3 levels) in create_worker' C:/Windows/Temp/ocr5F30.tmp/gemhome/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:inloop' C:/Windows/Temp/ocr5F30.tmp/gemhome/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in
block (2 levels) in create_worker' C:/Windows/Temp/ocr5F30.tmp/gemhome/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:incatch' C:/Windows/Temp/ocr5F30.tmp/gemhome/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in
block in create_worker' C:/Windows/Temp/ocr5F30.tmp/lib/ruby/gems/2.3.0/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
I am running the latest version of CodeDeploy at the time of writing (1.0.1.1518) and I've tried restarting the agent, restarting the box, and reinstalling the agent service. None of that made any difference.