Skip to content

Commit

Permalink
feat: allow to deploy lambda func locally (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
billmetangmo committed Jul 26, 2023
1 parent 27c4a71 commit c6e7d87
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 15 deletions.
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ If you are here, it means that you are interested in an in-house deployment of t


* Run the following commands:
```
```bash
cd infra/
terraform init
secretsfoundry run --script "terraform apply"
Expand All @@ -69,27 +69,44 @@ If you are here, it means that you are interested in an in-house deployment of t
### Pyramid test

#### Unit tests
```
cd api/
```bash
cd infra/api/
pytest test_extract.py
pytest test_notify.py
```

#### Integration tests

To launch integration tests locally :
```
```bash
act -j <job_name> --secret-file .env
```

#### End to end
To invoke register handler locally (lambda function):
```bash
cd infra/api
secretsfoundry run -p ../ --script "lambda invoke -v --config-file config-register.yaml"
```
To invoke scan handler locally (lambda function):
```bash
cd infra/api
secretsfoundry run -p ../ --script "lambda invoke -v --config-file config-scan.yaml"
```

#### End to end

```bash
sudo apt-get install -y chromium-browser
pip install -r requirements.txt
pip install -r infra/api/requirements.txt
pytest infra/api/test_liveness_mtchoun-mouh.py
```

### Application monitoring

The API Gateway and Lambda services save logs in CloudWatch.
The tracking of the visits on the website is done with https://fr.matomo.org/ (opensource alternative to Google Analytics).
Sentry is used to detection and tracking of errors (UI+backend)

### Application performance

Expand Down
19 changes: 9 additions & 10 deletions infra/.env
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
TF_VAR_MAINTAINER_MAIL="${aws-ssm(region=eu-central-1):/mtchoun-mouh/maintainer_mail}"
TF_VAR_WEBSITE_BUCKET_NAME="mtchoun-mouh"
TF_VAR_IMAGES_BUCKET_NAME="djansang2"
TF_VAR_SENTRY_DNS="${aws-ssm(region=eu-central-1):/mtchoun-mouh/sentry_dsn}"
TF_VAR_API_KEY="${aws-ssm(region=eu-central-1):/mtchoun-mouh/zulip_api_key}"
#source api/venv/bin/activate
# export TF_LOG="DEBUG"
GITHUB_HEAD_REF=develop
GITHUB_REF_NAME=test-branch
export REGION="eu-central-1"
API_KEY="${aws-ssm(region=eu-central-1):/mtchoun-mouh/zulip_api_key}"
BUCKET_NAME="${BRANCH_NAME}-djansang"
ENV="local"
LINKS_TABLE="mtchoun-mouh-${BRANCH_NAME}-Link_table"
MAINTAINER_MAIL="${aws-ssm(region=eu-central-1):/mtchoun-mouh/maintainer_mail}"
REGION="eu-central-1"
REGISTERS_TABLE="mtchoun-mouh-${BRANCH_NAME}-Register"
SENTRY_DNS="${aws-ssm(region=eu-central-1):/mtchoun-mouh/sentry_dsn}"
USERS_TABLE="mtchoun-mouh-${BRANCH_NAME}-Users"
6 changes: 6 additions & 0 deletions infra/api/config-register.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
region: eu-central-1

function_name: my_lambda_function
handler: lambda.register_handler
runtime: python3.8
# role: lambda_basic_execution
6 changes: 6 additions & 0 deletions infra/api/config-scan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
region: eu-central-1

function_name: my_lambda_function
handler: lambda.scan_handler
runtime: python3.8
# role: lambda_basic_execution
File renamed without changes.
1 change: 1 addition & 0 deletions infra/api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ requests==2.31.0
soupsieve==2.0.1
zulip==0.8.2
sentry-sdk==1.14.0
python-lambda==11.8.0

0 comments on commit c6e7d87

Please sign in to comment.