25

Scenario:

  • AWS Elastic Beanstalk
  • Java application
  • .ebextensions currently placed in src/main/resources/.ebextensions

Commands are not being executed.

Where is the .ebextensions supposed to go in a Java application?

Nikhil Sahu
  • 2,463
  • 2
  • 32
  • 48
flavian
  • 28,161
  • 11
  • 65
  • 105

5 Answers5

44

Using Maven I did as follows:

  • mkdir src/main/ebextensions
  • put .config files into this folder
  • add the following to pom.xml

        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <webResources>
                    <resource>
                        <directory>src/main/ebextensions</directory>
                        <targetPath>.ebextensions</targetPath>
                        <filtering>true</filtering>
                    </resource>
                </webResources>
            </configuration>
        </plugin>
    

to transfer the files to the top level of the war when it is built.

Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
  • As of 2017 this method does not appear to work. The plugin XML does, indeed, add the .ebextensions folder to the top level of the war, but when deployed to a beanstalk, that folder and its contents are nowhere to be found. – fivedogit Jan 02 '17 at 16:56
  • @fivedogit Did you look in the war file? When deployed to EBS, the folder is used up. – ATOzTOA Jan 09 '20 at 20:12
31

.ebextensions should be placed in the root of WAR.

The WAR structure looks like the following:

web_app.war
          |
          |_.ebextensions
          |   |_ 01run.config
          |   |_ 02do.config
          |
          |_META-INF
          |
          |_WEB-INF
               |_ classes
               |_ lib
               |_ web.xml

Refer to the official AWS docs for further information.

Ken Liu
  • 22,503
  • 19
  • 75
  • 98
study
  • 5,628
  • 4
  • 36
  • 44
  • 2
    My war is built using maven how would i modify my pom to achieve this – Paul Taylor Jun 27 '14 at 09:48
  • 3
    that's in src/main/webapp – Gustavo Matias Aug 28 '14 at 04:41
  • 3
    @GustavoMatias, AWS changed the path of `.ebextensions` for a while, but it accepts both paths(in `/WEB-INF/.ebextensions` and `/.ebextensions` of WAR). – study Aug 28 '14 at 06:44
  • 1
    @GustavoMatias no longer works in sbt version 0.13.6, now using jar uf target/scala-2.10/xxx-0.1.0-SNAPSHOT.war src/main/webapp/.ebextensions to insert the dir into the WAR file after packaging. – babalu Oct 23 '14 at 00:50
10

Using gradle I did the following

  • mkdir src/main/resources/ebextensions
  • put .config files into this folder
  • add the following to build.gradle

apply plugin: 'war'

war {
    from('src/main/resources/ebextensions') {
        into('.ebextensions')
    }
}

to transfer the files to the top level of the war when it is built.

hertzi
  • 2,809
  • 2
  • 14
  • 13
1

you missed resources, it works when I put the path right

war {
    from('src/main/resources/ebextensions') {
        into('.ebextensions')
    }
}
Thysy
  • 21
  • 2
  • This answer seems to place the .ebextensions folder in the root of the classes folder inside the generated JAR, not in the root of it. – christopher Jan 03 '17 at 10:26
1

Update for people here in 2020, now task name is "bootWar"

bootWar {
    from('src/main/resources/ebextensions') {
        into('.ebextensions')
    }
}
eold
  • 324
  • 4
  • 12