Table of contents

Official Content

This document tells you the prerequisites and steps to deploy applications (REST APIs) to AWS Lambda and AWS API Gateway.

"AWS Lambda lets you run code without provisioning or managing servers. You pay only for the compute time you consume - there is no charge when your code is not running." ref.: https://aws.amazon.com/lambda/

"Amazon API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale." ref.: https://aws.amazon.com/api-gateway

The main benefits of deploying to serverless platforms are the following:

  • No worry about infrastructure at all.
  • No need to manage, configure or install any web server. 
  • No need to rent or buy any server. 
  • 24/7/365 up time for (almost) free. (You pay only if the App is used. )

Technology used

  • AWS Lambda is used in order to Deploy Code that will be run in the Cloud. 
  • AWS API Gateway for Deploying REST Services. 
  • AWS Cloudfront for CDN
  • AWS S3 for Storage
  • AWS IAM for Credentials
  • Swagger definition for describing the API generated for our Application. 

Deployment Support

  • Service Backend for REST based Applications (Apple, Angular, Android)
  • API Objects

Restrictions

  • GeneXus Java Generator only (Highest JDK version supported: JDK11)
  • Multimedia content considerations
    • If using Image, Audio, Video, BlobFile data types => Storage Provider property must be used. This is because all App multimedia must be served from an external URL, such as Amazon S3. 
    • Cannot use FileSystem to serve content: File/read write access as Blob data type, Excel, PDF Reports. 
  • Temporal restrictions:
  • Max number of 600 services can be deployed per AWS Region. 
  • Beware
    • DBMS Connection Pooling does not work in Serverless.
      • This is because Serverless executes one Lambda Function per Request. So every Lamdba execution initialize a DB Pool. Thus, if 200 request are received at the exact same time, 200 lambdas are waken up, and 200 connections to DB will be opened.

How to use it

  1. Create AWS Serverless Infraestructure. Link
  2. Ensure Property Generate OpenAPI interface property is set to "Yes" at Generator Level and OpenAPI version property = OpenAPI 3.0
  3. ReBuild your GeneXus JAVA Application
  4. Using Application Deployment tool, select the Main Objects to Deploy. It must be a Smart Device Main Application or API Object. 
  5. From the Target Dropdown, select: "AWS Serverless Deploy"
  6. Fill required Deployment properties (obtained from Step (1), from the Stack Outputs):
    • AWS Access Key Id
    • AWS Secret Access Key
    • AWS Default Region
    • IAM Role Name
    • Application Name
    • Stage Name
  7. Click "Deploy"

That's it!

At the final step, GeneXus will print out the final URL.

You can use it now in the Smart Devices Generator's Services URL property or directly for APIObjects. 

Important notes:

  • Database Access

The AWS Lambda Function deployed must have access to the Database (should be in the same VPC and Security Group). You will have to configure it manually in the AWS Lambda Function Console. 

 AWSAccessKeyRequiresCustomPolicy_PNG

Troubleshooting

AWS Lambda supports up to JDK11. You need either compile with JDK11 (or lower), or use any JDK but set  "Compiler Options" property to: "-source 1.8 -target 1.8"

com/kbaux/GXApplication has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0","errorType":"java.lang.UnsupportedClassVersionError

Availability

Since GeneXus 17 upgrade 7

See Also

https://aws.amazon.com/api-gateway/pricing/ (As of September 2018: "The Amazon API Gateway free tier includes one million API calls received per month for up to 12 months.")
https://aws.amazon.com/lambda/pricing/ (As of September 2018: "The Lambda free tier includes 1M free requests per month and 400,000 GB-seconds of compute time per month.")
Serverless computing - The next evolution of Cloud Computing by Gonzalo Gallotti (Presented at #GX27, Spanish only, 30 mins)
How to deploy a command line procedure to AWS Lambda as a Function

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant