The Circle API project, created with aws-serverless-java-container
.
This project serves as the backend for the Circle app. It is a Serverless application, built with AWS Lambda and Amazon API Gateway. It is built with AWS SAM and AWS CloudFormation. The project leverages the aws-serverless-java-container
to run a Spring Boot 2 REST API in a Lambda function.
The project folder also includes a template.yml
file. You can use this SAM file to deploy the project to AWS Lambda and Amazon API Gateway or test in local with the SAM CLI.
You can use the SAM CLI to quickly build the project
$ sam build
Building codeuri: /home/camjl/repos/cs4800/api runtime: java17 metadata: {} architecture: x86_64 functions: ApiFunction
Running JavaMavenWorkflow:CopySource
Running JavaMavenWorkflow:MavenBuild
Running JavaMavenWorkflow:MavenCopyDependency
Running JavaMavenWorkflow:MavenCopyArtifacts
Build Succeeded
Built Artifacts : .aws-sam/build
Built Template : .aws-sam/build/template.yaml
Commands you can use next
=========================
[*] Invoke Function: sam local invoke
[*] Deploy: sam deploy --guided
From the project root folder - where the template.yml
file is located - start the API with the SAM CLI.
$ sam local start-api
...
Mounting com.amazonaws.serverless.archetypes.StreamLambdaHandler::handleRequest (java17) at http://127.0.0.1:3000/{proxy+} [OPTIONS GET HEAD POST PUT DELETE PATCH]
...
To deploy the application in your AWS account, you can use the SAM CLI's guided deployment process and follow the instructions on the screen
$ sam deploy --guided
Once the deployment is completed, the SAM CLI will print out the stack's outputs, including the new application URL. You can use curl
or a web browser to make a call to the URL
...
-------------------------------------------------------------------------------------------------------------
OutputKey-Description OutputValue
-------------------------------------------------------------------------------------------------------------
ApiApi - URL for application https://xxxxxxxxxx.execute-api.us-west-2.amazonaws.com/Prod/
-------------------------------------------------------------------------------------------------------------