Skip to content

joumenharzli/serverless-aws-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless exemple with Java and AWS

An exemple for using serverless with aws and java

Donations

If you find my work useful, consider donating to support it :)

Image of Ethereum Ethereum

You can simply scan this QR code to get my Ethereum address

My QR Code

Configuration

Start by creating a user with programmatic-access-only in AWS having the following roles

  • AmazonS3FullAccess
  • CloudWatchLogsFullAccess
  • IAMFullAccess
  • AWSLambdaFullAccess
  • CloudFormationFullAccess
  • AmazonAPIGatewayAdministrator

Install serverless

$ npm install -g serverless

Setup credentials with serverless

$ serverless config credentials --provider aws --key <key> --secret <secret>

Build and deployment

First build

We need to create a lambda layer that contains the java dependencies

$ cd serverless
$ mvn clean package
$ cd ../javalibs-layer
$ serverless deploy

Then deploy the serverless application

$ cd serverless
$ serverless deploy

Development

if the dependencies was not changed you can simply build and deploy the project

$ cd serverless
$ mvn clean package
$ serverless deploy

Testing

You can test a function using

$ serverless invoke --function add-transaction --data '{"pathParameters":{"accountId":"123"},"body":"{\"amount\": 1234}"}'

To see logs use

$ serverless logs --function add-transaction 

Via Curl

$ curl -X POST https://xxxx.execute-api.us-east-1.amazonaws.com/dev/accounts/123/transactions --data '{"amount":1234}'

Releases

No releases published

Packages

No packages published

Languages