java maven deployed in elastic bean stalk how to install 3rd party package -> wkhtmltopdf


I built a java app using the vaadin-flow framework with maven and java 17.

I already deployed the app in elastic bean stalk, connected it to a domain and its working properly.

Right now i want to install wkhtmltopdf for pdf creation on every ec2 instance for my app, it is my understanding that i need to use .ebextensions but how exactly will i describe this, what i want to run on the ec2 instance are the below 2 commands:


sudo yum install wkhtmltox-0.12.6-1.amazonlinux2.aarch64.rpm

As per my understanding i need to create a .ebextensions directory and add the .config file inside which will describe the commands i want to run, but can't figure out how to write or package this file so my question is, Is there any java maven example that uses a .ebextensions directory and deploys a 3rd party package to elastic bean stalk.

asked a year ago360 views
1 Answer
Accepted Answer

The following is an elegant way to manage an .ebextensions directory and build with maven using the maven-assembly-plugin:

  1. Create the .ebextensions directory under the root folder of your project (see screenshot) Project structure

  2. Create the following wkhtmltox.config file inside

    mode: "000600"
    owner: root
    group: root
    command: sudo yum localinstall -y /tmp/wkhtmltox.amazonlinux2.rpm


  • adjust the URL according to the version and platform/cpu architecture
  • added parameter -y to automatically confirm the installation when executed programatically
  • switched from install to localinstall as we need return code 0 (success) also when the package is already installed (which will happen on the 2nd+ deployment)
  • syntax see [3]
  1. Extend pom.xml to use the maven-assembly-plugin to build a zip file which contains the applications jar file and the .ebextensions directory (without top level directory).
  1. In the project root directory create the corresponding configuration file for the assembly plugin named zip-with-ebextensions.xml
<assembly xmlns=""
        <!-- <include>Procfile</include> -->

Note: can be extended by including a Procfile (see [2]) if needed.

  1. Build your project with mvn package -Pproduction

Result: The target directory should contain a zip file named <app_name_with_version> The contents should look like: Enter image description here

When you login to the underlying EC2 instance, you can see that wkhtmltopdf was installed: Enter image description here

Final remark: The structure should also work, if you decide to deploy source code using e.g. the Elastic Beanstalk Command Line Interface (EB CLI), and build on the EC2 instance (see [1])

Related AWS Elastic Beanstalk documentation references:

answered a year ago
profile picture
reviewed a month ago
  • Hi Norman, the above worked perfectly fine! thank you so much for this answer, couldn't have asked for a better answer!

  • Excellent !!!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions