7

I'm deploying a Windows / .NET MVC app on Elastic Beanstalk, and managed to get through most of the challenges except for one.

The webapp in question creates a local cache for binary assets in a subfolder of its current deployment location, and for this to work I need to add permissions for the IIS_IUSRS group to read/write to that folder.

After a long trial-and-error exercise I now have a solution that seems to work, but I am not 100% sure of the "legality" of it...

In the MVC solution, I created a folder named ".ebextensions", and in it a yaml file named "eb.config".

In this file I basically create 2 batch files that I deploy to c:\temp - the first batch file checks if there is already a copy of the 2nd file in C:\Program Files\Amazon\ElasticBeanstalk\hooks\appdeploy\post, and if not, copies it there.

The 2nd batch file sets the required ACL for this "BinaryData" folder. Elastic Beanstalk executes any batch file it finds in the folder mentioned above, and this seems to do the trick for now.

I haven't been able to find any documentation on how to achieve this "officially", and found out about this trick from this blogpost.

Any suggestions on how to achieve this in a "cleaner" way would be much appreciated.

1
7

It's 2019 and I still couldn't find any documentation for Beanstalk Platform Hooks regarding .NET apps. I ended up doing something similar to your solution.

  1. Create a config file in .ebextensions folder.
  2. Create a script file that I want to run (either save it in the code, or define/retrieve it as part of the config file in Step 1)
  3. Inside this config file, under container_commands section, run a command to copy the script from Step 2 into C:\Program Files\Amazon\ElasticBeanstalk\hooks\appdeploy\post\ (or whichever hook you want). More info here

When Beanstalk deploys the application, the command under container_commands will run after the server has been set up, but before the code has been deployed 1. After that, your hook script should be in place and will trigger according to the folder it's in.

Unfortunately I don't know if this is the official way to do it for .NET apps.

2
  • I can also confirm this works. Very frustrating to have to go this route when it would seem logical to have a post install section directly in .ebextensions – Particleman Sep 1 '19 at 2:33
  • If it works this is a good workaround but I'm guessing the intended method is to use the .ebextensions "files" command to generate your script in the desired location (link below). I think this is likely less frustrating and fewer steps/more clean solution? docs.aws.amazon.com/elasticbeanstalk/latest/dg/… – NoPathInParticular Jan 6 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.