I'm working on setting up our build process to utilize AWS code deploy with an autoscaling group. I've managed to get the code built and zipped with an appspec.yml and BeforeInstall.bat file all moved up to S3 correctly. Code deploy properly pulls down the zip file, unzips it and calls the BeforeInstall.bat. The batch file has 3 steps
It properly gets through steps 1 and 2, but then when it gets to step 3 it calls msdeploy and returns this error:
Error: There was an error reading IIS configuration schema from 'C:\Windows\system32\inetsrv\config\schema\'
Thinking that it's likely a permission issue, I logged onto one of the servers and ran the cmd script manually. It deploys fine, which isn't surprising given that I logged on as an Admin. I then opened a powershell script as the LocalSystem
user (which is what the CodeDeploy Host Agent Service
runs as) and ran the cmd script. It completed successfully. I ran the whole batch file as the LocalSystem
user. It ran successfully.
I then went back and added echo %username%
to the batch script, committed, built, and ran a new deployment. I see this user in the code deploy logs WIN-49GNL2FRHJ4$
. The deployment still fails. When I run the batch script on the box from a powershell window as Administrator
, I of course see Administrator
echoed out. The script succeeds. When I run the batch script from a powershell window as the LocalSystem
I see WIN-49GNL2FRHJ4$
, just as when it's run from CodeDeploy via the AWS console, but it successfully runs.
What is different between how the AWS console calls that batch file as the LocalSystem
user and how I call it as that user via a powershell window?
Looks like the issue was having an old version of Web Deploy installed. I went to look for logs and realized that I had somehow installed v2 (probably the default when I installed IIS onto the EC2 instance). I downloaded and installed the latest version (v 3.6 as of this writing) and created a new deploy. The code deployed as expected.