I've been trying to give the IIS APPPOOL\DefaultAppPool user write permissions to two folders under the wwwroot folder using the .ebextensions container_commands.
There are two scenarios that I need to cover:
- Be able to grant the DefaultAppPool user write permissions when publishing to a new EBS environment where the wwwroot folder does not contain my solution when .ebextensions run.
- Be able to republish to an existing EBS environment and keep the DefaultAppPool write permissions where the wwwroot folder does contain my solution when .ebextensions run.
I have been able to perform the latter but not the former. The former fails because I'm specifying the path to the folders under wwwroot who's permissions I want to change but the solution has yet to be deployed to wwwroot resulting in an error message: "The system cannot find the file specified."
I've tried an other approach where I give DefaultAppPool write permissions to the whole wwwroot folder hoping that when the project is extracted, the newly added folders would inherit the permissions from wwwroot. When I do this, and log to a file the output of the icacls command, I can verify that the write permissions are indeed added for wwwroot. In spite of being able to verify that the write permissions are added when the .ebextensions run, they somehow get changed back to their original state (only read) later in the deployment process, likely by:
c:\Program Files\Amazon\ElasticBeanstalk\Tools\Deploy.exe
This is the .config file I used to verify that the permissions changed:
container_commands:
00_dir:
command: dir c:\inetpub\wwwroot >> c:\cfn\perms.log 2>&1
waitAfterCompletion: 0
01_what_perms:
command: icacls.exe c:\\inetpub\\wwwroot >> c:\\cfn\\perms.log 2>&1
waitAfterCompletion: 0
02_changeperm:
command: icacls.exe c:\\inetpub\\wwwroot /grant "IIS AppPool\DefaultAppPool":(OI)(CI)W >> c:\\cfn\\perms.log 2>&1
waitAfterCompletion: 0
03_what_perms:
command: icacls.exe c:\\inetpub\\wwwroot >> c:\\cfn\\perms.log 2>&1
waitAfterCompletion: 0
04_dir:
command: dir c:\inetpub\wwwroot >> c:\cfn\perms.log 2>&1
waitAfterCompletion: 0
Thus I ask:
Is there a way to grant the DefaultAppPool user write permissions to these two folders that works both when publishing to a new EBS environment and when republishing to an existing one?
Is there a way to run commands after the application has been deployed to wwwroot, but not before as container_commands do?
When I look at the logs from my .ebextensions .config files I see that they are run twice, is that normal?