We have deployed ASP.Net Core app on AWS EBS and have problem with writing files on it.
Access to the path
C:\inetpub\AspNetCoreWebApps\app\App_Data\file.txt
is denied
I added .ebextensions\[app_name].config
but it did nothing
{
"container_commands": {
"01": {
"command": "icacls \"C:/inetpub/AspNetCoreWebApps/app/App_Data\" /grant DefaultAppPool:(OI)(CI)"
}
}
}
I know that this is permission problem because when I RDP to machine and changed permission manually it solved problem. I would like to it during deploy using .ebextensions\[app_name].config
.ebextensions\[app_name].config
run before deploy and during deploy folder was recreated - that why it was not working. I fixed it by adding postInstall
Power Shell script into aws-windows-deployment-manifest.json
:
"scripts": {
"postInstall": {
"file": "SetupScripts/PostInstallSetup.ps1"
}
# # PostInstallSetup.ps1 #
$SharePath = "C:\inetpub\AspNetCoreWebApps\app\App_Data"
$Acl = Get-ACL $SharePath
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("DefaultAppPool","full","ContainerInherit,Objectinherit","none","Allow")
$Acl.AddAccessRule($AccessRule)
Set-Acl $SharePath $Acl