Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 and put this in the top level .ebextensions folder in my project. The contents are below:

commands:
  0_mkdir:
    command: mkdir C:\\AppFolder\\

  1_set_iuser_permissions:
    command: cacls C:\\AppFolder\\ /t /e /g IUser:f IIS_Users:f

However while the folder is created successfully the permissions aren't set. If anyone has any idea what I am doing wrong I would be hugely grateful. Big thanks in advance.

like image 512
fhevol Avatar asked Feb 20 '15 04:02

fhevol


People also ask

What is Elastic Beanstalk config Yml?

Elastic Beanstalk supports two methods of saving configuration option settings. Configuration files in YAML or JSON format can be included in your application's source code in a directory named . ebextensions and deployed as part of your application source bundle. You create and manage configuration files locally.

Where is Elastic Beanstalk config file?

Saved configurations are stored in the Elastic Beanstalk S3 bucket in a folder named after your application. For example, configurations for an application named my-app in the us-west-2 region for account number 123456789012 can be found at s3://elasticbeanstalk-us-west-2-123456789012/resources/templates/my-app .

How do I set environment variables in Elastic Beanstalk?

Open the Elastic Beanstalk console , and in the Regions list, select your AWS Region. In the navigation pane, choose Environments, and then choose the name of your environment from the list. If you have many environments, use the search bar to filter the environment list. In the navigation pane, choose Configuration.


1 Answers

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.

like image 171
fhevol Avatar answered Nov 15 '22 00:11

fhevol