Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeDeploy on Windows EC2 Permission Denied

Just looking for some advice on doing CodeDeploy on Windows. I've used it for a year on Linux boxes, this is my first Windows Server on EC2 and I can't seem to get past "Permission Denied" errors.

I've changed the permissions in Windows on the folders, but the Deploy is failing on the Install step on CodeDeploy.

Error CodeUnknownError
Script Name
MessagePermission denied - c:/inetpub/render
Log Tail

appspec.yml

version: 0.0
os: windows
files:
 - source: /
   destination: /inetpub/render
hooks:
  AfterInstall:
    - location: aws/scripts/deploy.bat
      runas: administrator
      timeout: 1200

I've tried both Windows and Linux style pathing (C:\inetpub\render) because examples aren't clear, but nothing has worked.

like image 605
Kris White Avatar asked Aug 29 '26 06:08

Kris White


1 Answers

In my case the "Permission denied @ unlink_internal" was caused by dotnet.exe process locking one of the dll's. You can find out what locks your file using Microsoft Process Explorer. You can then update your appspec.yml BeforeInstall hook to kill the process before files are updated:

version: 0.0
os: windows
files:
  - source: \files
    destination: C:\inetpub\wwwroot\yoursite
hooks:
  BeforeInstall:
    - location: stopsite.bat
      timeout: 300
      runas: Administrator
  AfterInstall:
    - location: startsite.bat
      timeout: 300
      runas: Administrator

Where stopsite.bat contains the following commands:

C:\Windows\System32\inetsrv\appcmd stop site "yoursite"
taskkill /IM "dotnet.exe" /F
like image 80
Michal Wysocki Avatar answered Sep 02 '26 15:09

Michal Wysocki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!