no

How to Deploy a Quarkus RESTEasy Microservice as AWS Lambda Function

1. Introduction This article will teach us how to deploy a RESTEasy microservice in Quarkus as an  AWS Lambda function. 2. What is A...

1. Introduction

This article will teach us how to deploy a RESTEasy microservice in Quarkus as an AWS Lambda function.

2. What is AWS Lambda?

AWS Lambda is a serverless computing platform commonly used to perform an event-driven function. But with the recent updates, it can also be used to handle HTTP and REST requests. This entails a significant saving in cloud usage fees compared to other services where containers can be run like AWS Fargate and EC2. Especially if the service is not in use 24/7.

3. What is Quarkus?

Quarkus is another Java framework similar to Spring but optimized to make it more efficient for containers, cloud, and serverless environments. It also provides a library quarkus-amazon-lambda-rest used to deploy a RESTEasy (JAX-RS) microservice as a Lambda function using AWS Gateway REST API.

4. What do you need to Create a Quarkus Project?

You can use the project starter creator available at: https://code.quarkus.io.

Or use the Quarkus plugin in IntelliJ or Eclipse to create a Quarkus project template.


Quarkus project in IntelliJ.

5. What do you need to Deploy a Quarkus Lambda Function on AWS?

Before you begin, initialize your AWS credential on your local machine. Follow the guide at https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html.

5.1 Install the following Tools

  • Chocolatey (Windows), Homebrew (Mac)
  • Quarkus CLI - https://quarkus.io/guides/cli-tooling
  • AWS SAM CLI - https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html
Make sure to follow the guide that matches your computer and install all the prerequisites if there are given.

6. Quarkus CLI

You can now use Quarkus CLI to run your project:

>quarkus dev


Or create a build:

>quarkus build


This command should build various files in the target folder such as sam.jvm.saml and function.zip which we will use later in the deployment.

7. Deploy your Quarkus Lambda Function

Make sure you have built your project and set up the AWS credential.

Let's do the deployment.

>sam deploy -g -t target/sam.jvm.yaml


Installation Summary.



The sam.jvm.yml file contains the AWS CloudFormation resources this command will create on AWS. First, it will list these resources for you to verify, and once you are satisfied hit enter.

8. Removing the Quarkus Lambda

Don't remove the function from the Lambda screen, instead go to CloudFormation to remove all the associated resources.

9. More Quarkus AWS Libraries

Aside from AWS Lambda, more AWS libraries are available in the Quarkus framework such as XRay, Alexa, HTTP, etc.

Related

serverless 3356235896073737916

Post a Comment Default Comments

item