Minimally Opinionated Serverless Microservice Project
- Install Java 8, Groovy, Kotlin, and Gradle - I highly recommend using SDKMAN to install any JVM-related packages.
- Install NodeJS and the Serverless Framework
- Amazon Web Services, GitHub, Travis CI, CodeCov and Sentry accounts
Create a new Serverless project
Using the Serverless Framework, you can create a new project by providing the base template microservice-starter:
serverless create \ --template-url https://github.com/bytekast/serverless-templates/tree/master/microservice-starter \ --path myservice
This project is pre-configured to use the following development tools and services:
- Groovy / Kotlin - Development Languages
- Gradle - Dependency Management and Build Tool
- Spock - Test/Specification Framework
- Serverless Framework - Serverless Management and Deployment Toolkit
- Travis CI - Continuous Integration and Continuous Deployment
- Jacoco / CodeCov - Code Coverage
- Sentry - Automatic Error and Bug Tracking
This project makes a few assumptions before you are able to deploy the service in AWS.
First, you need to setup your AWS credentials/profiles in
[dev] aws_access_key_id = XXXXXXXXXXXXXX aws_secret_access_key = XXXXXXXXXXXXXX region = us-east-1 [prod] aws_access_key_id = XXXXXXXXXXXXXX aws_secret_access_key = XXXXXXXXXXXXXX region = us-east-1
Now you can go to the project directory, build the binaries and deploy to the
Test the functions locally or invoke the real instance in AWS to verify:
Additional Conventions / Configurations
Bug Tracking and Error Reporting:
- This project uses Log4J to automatically create trackable bug issues in Sentry whenever a message with the
ERRORseverity is logged via
- Update the serverless.env.yml file to provide the
SENTRY_DSNenvironment variable so that issues are created in the appropriate project in Sentry.
Travis CI for Continuous Integration
- When the project is enabled in Travis CI, the provided
travis.ymlwill autodeploy the service to the dev AWS Environment.
DEV_AWS_SECRETenvironment variables must be provided in .travis.yml.
- Code Coverage reports are automatically uploaded to CodeCov if the
CODECOV_TOKENenvironment variable is provided in .travis.yml.