If you wish to deploy your application to Amazon’s Elastic Beanstalk, then you can customize your server setup by placing configuration files within a .ebextensions directory within the root of your .war file (for web applications). These files can then contain various kinds of instructions. One can install packages with package managers such as yum or rpm. It is also possible to add files or issue commands and more. For an overview of the possibilities, please see the official documentation.
This article will show you how to place the .ebextensions directory at the root of your war file. An easy way of doing this is to package your war file with Maven. This assumes that your project is a Maven project and has a pom.xml file at the root of the project.
What you have to do is to instruct the maven-war-plugin to move the .ebextensions directory to the root of the war file. This can be done like in the below example (within pom.xml).
<plugin> <artifactId>maven-war-plugin</artifactId> <version>2.6</version> <configuration> <webResources> <resource> <directory>src/main/ebextensions</directory> <targetPath>.ebextensions</targetPath> <filtering>true</filtering> </resource> </webResources> </configuration> </plugin>
Then, provided that your project is set to use war packaging within your pom.xml, you can issue the following command from the Terminal (with the working directory at the project root).
This will place a war file at the project’s target directory with the .ebextensions directory at the root. To verify that the directory has been moved correctly, then you can unpack or view .war files contents.