title: What is the proper way to create .ebextensions for AWS Beanstalk through maven for Spring Boot app
body: <p>We have to customize <code>hosts</code> file in our dynamically generated Elastic Beanstalk instance of our Spring Boot application during our GitLab CI/CD pipeline. To do this, we need to provide a <code>.ebextensions</code> directory with a config file that looks like this:</p>
  
  <pre><code>commands:
    01_add_hosts:
      command: echo 123.12.12.123 myhost.com &gt;&gt; /etc/hosts
  </code></pre>
  
  <p>Since we have a spring boot application, we have to package <code>.ebextensions</code> at the root level of our fat jar. So, basically we unzip the jar, add the ebextensions directory and zip it back. This way we successfully achieve the Beanstalk customization in our Gitlab pipelines.</p>
  
  <p>However, to make this process we use <code>maven-antrun-plugin</code> like this:</p>
  
  <pre><code>&lt;!-- Bundle .ebextensions inside jar --&gt;
  &lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
      &lt;version&gt;1.8&lt;/version&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;id&gt;prepare&lt;/id&gt;
              &lt;phase&gt;package&lt;/phase&gt;
              &lt;configuration&gt;
                  &lt;tasks&gt;
                      &lt;unzip src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.directory}/${project.build.finalName}" /&gt;
                      &lt;copy todir="${project.build.directory}/${project.build.finalName}/" overwrite="false"&gt;
                          &lt;fileset dir="./" includes=".ebextensions/**"/&gt;
                      &lt;/copy&gt;
                      &lt;zip compress="false" destfile="${project.build.directory}/${project.build.finalName}.jar" basedir="${project.build.directory}/${project.build.finalName}"/&gt;
                  &lt;/tasks&gt;
              &lt;/configuration&gt;
              &lt;goals&gt;
                  &lt;goal&gt;run&lt;/goal&gt;
              &lt;/goals&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>The problem is that <code>maven-antrun-plugin</code> is and old plugin from 2014 and this looks like not the proper way to achieve this bundle jar. </p>
  
  <p>Do you how or what it is the spring boot way to create this bundle jar? I mean add directories/files at the root level of the jar in spring boot? Bear in mind that we bundle this at our pipeline job time that deploys through AWS Beanstalk maven plugin.</p>