This repository serves as a clonable template for service AWS lambda service architecture.
Clone this repository, and change the services to suit the needs of your new service. We have provided a few examples in the examples folder.
Here are some articles that we suggest you familiarize yourself with first:
To setup the service, ensure that you have terraform installed and localstack service operational.
If you're running the setup process locally, then execute the following block, otherwise you can skip it:
cd terraform/
cat > local.tf <<'EOF'
terraform {
backend "local" {
path = "tfstate/terraform.tfstate"
}
}
EOF
Remember that this repository is responsible for definition of Lambda functions and it's not standalone - we cannot run it without integration to 3rd part services. To have operational endpoint where this logic will be attached we have to setup also the Root Service
The repository contains a few directories:
examples
- contain many useful documents and sample requests which might be useful to gather knowledge about our services before touching code.sources
- source code of our lambda functionsterraform
- defitions of terraform resources.
Currently, we have few Terraform files:
main.tf
- localstack provider configuration.resources.tf
- resource definitions such as DynamoDB, Lambda, etc.outputs.tf
- This file describes output of Terraform execution.variables.tf
- definitions of global variables available in templates
Lambda functions are easily testable. To create tests for particular function we have to create tests in specs
directory. To run tests just go to the specs
directory and execute command rspec lambda1_spec.rb
.
Remember that in testing environment we don't have fully functional and repeatable routing environment so we have to mock all invocations of particular function.
If in guides you will find prefix [Root Service]
it means that you have to setup this part inside Root Service