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 41f4582
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 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
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

1 comment on commit 41f4582

@billmetangmo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Plan Failed

CI link

Plan: 21 to add, 0 to change, 0 to destroy.
  • Create
    • aws_api_gateway_deployment.test
    • aws_api_gateway_integration.integration
    • aws_api_gateway_method.method
    • aws_api_gateway_method_response.method_response_200
    • aws_api_gateway_resource.resource
    • aws_api_gateway_rest_api.api
    • aws_cloudwatch_event_rule.scheduler
    • aws_cloudwatch_event_target.target
    • aws_dynamodb_table.Link_table
    • aws_dynamodb_table.Register
    • aws_dynamodb_table.Users
    • aws_lambda_function.lambda
    • aws_lambda_function.scan
    • aws_lambda_permission.allow_cloudwatch_to_call_check_foo
    • aws_lambda_permission.apigw_lambda
    • aws_s3_bucket.images
    • local_file.index_page
    • module.cors.aws_api_gateway_integration._
    • module.cors.aws_api_gateway_integration_response._
    • module.cors.aws_api_gateway_method._
    • module.cors.aws_api_gateway_method_response._

Please sign in to comment.