How To Set Folder Permissions in Elastic Beanstalk Using YAML File?

前端 未结 3 1368
梦谈多话
梦谈多话 2021-01-05 16:46

I have a C# Web API Elastic Beanstalk app which needs a folder outside the deployment directory that the IUSER and IIS_USERS users can write to. I\'ve created a .config file

相关标签:
3条回答
  • 2021-01-05 17:13

    It looks like you are using invalid .net accounts (unless these are custom accounts you created). That is part of the reason why your permissions are not being set. They should be IUSR or IIS_IUSRS

    Furthermore, container_commands executes after your app/server environment has been setup, but before your deployment has started. There is no other way to set permissions on files/folders within your deployment directory other than using a wpp.targets file within visual studio.

    The following SO post is a good read using wpp.targets to solve your issue. Can Web Deploy's setAcl provider be used on a sub-directory?

    0 讨论(0)
  • 2021-01-05 17:21

    In the end I switched to using Json instead of YAML as, despite my YAML being validated by several online YAML testers, AWS still wouldn't accept it. It always had issues with the parameters passed to icacls. I also changed to a folder within the application App_Data folder as setting permissions on any directory external to the application didn't appear to work. So, my final configuration file is as follows:

    {
        "container_commands": {
            "01": {
                "command": "icacls \"C:/inetpub/wwwroot/AppName_deploy/App_Data/AppFolder\" /grant DefaultAppPool:(OI)(CI)F"
            }
        }
    }
    

    Hope this helps someone else out.

    0 讨论(0)
  • 2021-01-05 17:39

    Place a file 01_fix_permissions.config inside .ebextensions folder.

    contents:

    files:
      "/opt/elasticbeanstalk/hooks/appdeploy/pre/49_change_permissions.sh":
        mode: "000755"
        owner: root
        group: root
        content: |
          #!/usr/bin/env bash
          sudo chown -R ec2-user:ec2-user tmp/
    
    0 讨论(0)
提交回复
热议问题