Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

uujo/lambda_localstack_template

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nci-aws-lambda-localstack-template

This provides a templates for aws lambda test in local environment using localstack or local server instances (i.e. dynamoDB). This examples shows only fraction of the services localstack provides. The full list of services are here. This template provides the basic settings for local test which can be used in different projects with minimal configuration changes. Details for the configuration changes is explained How to use this template section below.

Prerequesite (on Mac)

getting the source code

git clone https://github.com/BIAD/nci-aws-lambda-localstack-template.git

cd lambda-localstack-template

Set up git hooks (pre-commit, pre-push) - This is one time setting. Doesn't have to be repeated every time.

This will copy the pre-commit, pre-push files under .git/hooks

> git config --local init.templatedir './.git_templates'
> git init

Pre commit: change the format using Black and Pylint checking (Will fail to commit if pylint score is not 10.

Pre push: check the unittest and code coverage (Will fail to push if either unittest fails or code coverage is less than 95%

For special cases, if you still need to commit, push the code use --no-verify option on git commands

> git commit --no-verify
> git push origin [branch_name] --no-verify

set PYTHONPATH for unittest

export PYTHONPATH=$PWD/src:$PWD/tests:$PYTHONPATH

If virtual environment is used below, you can set the above path in .venv/bin/activate file

Local test set up using aws sam and localstack (with python3 venv) - virtual environment setting is optional.

  • set the virtual environment (optional, you can use other virtual env tools or without it)

    cd lambda-localstack-template

    python3 -m venv .venv

    source .venv/bin/activate - activate virtual environment

    pip install -r requirements.txt - one time setting (If install fails with xcun error, run xcode-select --install)

  • Now it is ready to set up the test below.

  • After all the test is done. get out of virtual environment.

    deactivate

Tests Examples

Integration Test: To be added

  • goal: With minimal configuation change, testing environment can be set up for different project.
  • There are two main configuration - One for localstack and one for sam. If starting and stop scrip need to be changed as well if you want to reuse the script.

Reference

About

Template for lambda with localstack and sam integration for localtest

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  
Morty Proxy This is a proxified and sanitized view of the page, visit original site.