Where to add .ebextensions in a WAR?
Asked Answered
M

5

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?

Marnamarne answered 24/8, 2013 at 22:47 Comment(0)
S
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.

Shackleton answered 28/8, 2013 at 22:28 Comment(4)
My war is built using maven how would i modify my pom to achieve thisLindbergh
that's in src/main/webappTolliver
@GustavoMatias, AWS changed the path of .ebextensions for a while, but it accepts both paths(in /WEB-INF/.ebextensions and /.ebextensions of WAR).Shackleton
@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.Plastometer
L
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.

Lindbergh answered 3/7, 2014 at 11:49 Comment(2)
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.Alitta
@Alitta Did you look in the war file? When deployed to EBS, the folder is used up.Cheeseburger
S
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.

Shackleton answered 28/8, 2013 at 22:28 Comment(4)
My war is built using maven how would i modify my pom to achieve thisLindbergh
that's in src/main/webappTolliver
@GustavoMatias, AWS changed the path of .ebextensions for a while, but it accepts both paths(in /WEB-INF/.ebextensions and /.ebextensions of WAR).Shackleton
@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.Plastometer
H
11

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.

Highness answered 14/10, 2015 at 13:29 Comment(0)
D
1

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

war {
    from('src/main/resources/ebextensions') {
        into('.ebextensions')
    }
}
Doorstep answered 11/9, 2016 at 0:3 Comment(1)
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.Darceldarcey
T
1

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

bootWar {
    from('src/main/resources/ebextensions') {
        into('.ebextensions')
    }
}
Tempera answered 12/4, 2020 at 16:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.