GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ArnauAregall/aws-lambda-spring-cloud-function: Exploring Spring Cloud Function, AI and AWS Lambda: building a native serverless application with Kotlin powered by OpenAI.

BranchesTags
Open more actions menu

Latest commit

 

History

41 Commits
41 Commits

Folders and files

NameName
Last commit message
Last commit date
aws-image
aws-image
 
 
gradle/wrapper
gradle/wrapper
 
 
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
build.gradle.kts
build.gradle.kts
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
samconfig.toml
samconfig.toml
 
 
settings.gradle.kts
settings.gradle.kts
 
 
template.yml
template.yml
 
 

Repository files navigation

aws-lambda-spring-cloud-function

Demo project to showcase how to build an AWS Lambda using:

  • Kotlin
  • Gradle
  • GraalVM
  • Spring Boot 3
  • Spring Reactive Web (WebFlux, Netty framework)
  • Spring Cloud Function
  • OpenMeteo API
  • OpenAI API
  • Docker & Testcontainers

Articles that were written based in this project:

  • Exploring Spring Cloud Function, AI and AWS Lambda: building a native serverless application with Kotlin powered by OpenAI.

Requirements

The application requires JDK 17 at least on a GraalVM distribution.

$ sdk install java 22.3.r17-grl
$ sdk use java 22.3.r17-grl

Build and test

./gradlew build

Running the application

On a JDK

./gradlew bootRun

Natively

./gradlew nativeRun

Building the native AWS Lambda artifact with SAM

Linux:

sam build

macOS:

AWS Lambda requires native applications to be built in an Amazon Linux compatible OS, so on macOS we need to run the build in a compatible Docker container.

  1. Build the Docker image compatible with AWS Linux:

    ./aws-image/build-aws-image.sh
  2. Run sam build specifying the Docker image:

    sam build --use-container --build-image tech.aaregall.lab/amazonlinux-graalvm:latest

Deploy the application as an AWS Lambda using SAM

Define the following environment variables on the deployment host.

export AWS_REGION=...
export OPENAI_API_KEY=...

Deploy the Lambda application

sam deploy --region $AWS_REGION --parameter-overrides ParameterKey=OpenAiApiKey,ParameterValue=$OPENAI_API_KEY

See CloudWatch logs

sam logs -n SpringCloudFunctionLambda --stack-name aws-lambda-spring-cloud-function

Delete the Lambda application

sam delete SpringCloudFunctionLambda

About

Exploring Spring Cloud Function, AI and AWS Lambda: building a native serverless application with Kotlin powered by OpenAI.

aregall.tech/aws-lambda-spring-cloud-function-kotlin-graalvm-native-openai

Topics

awsdockergraalvmkotlinlambdaspring-bootspring-cloud-functiontestcontainers

Resources

Readme
Apache-2.0 license
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.