You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
# aws-lambda-python
2
-
An implementation of the Open MPIC API using AWS-Lambda serverless functions written in Python as well as AWS API Gateway.
2
+
An implementation of the Open MPIC API using AWSLambda serverless functions written in Python as well as AWS API Gateway.
3
3
4
4
# Deployment
5
5
As this API runs serverless in the cloud, it is not installed but rather deployed. The below instructions deploy the API in a user's AWS account and create a unique API endpoint for that user.
6
6
7
7
## Requirements
8
-
All requirements for running the API are packaged and uploaded to AWS as a lambda layer. However, the machine deploying the API must have the following requirements
8
+
All requirements for running the API are packaged and uploaded to AWS as a Lambda layer. However, the machine deploying the API must have the following requirements:
9
9
- The AWS CLI (https://aws.amazon.com/cli/) installed with default profile login credentials. The script currently uses the "default" profile to deploy the API to. If you have multiple AWS profiles, ensure the one you want to use for the API in listed as default in ~/.aws/credentials. You can alternatively change the AWS module parameters in main.tf to use an alternate profile.
10
10
- Open Tofu (https://opentofu.org/) is installed. This is an open-source fork of Terraform and the configs in this project are largely interoperable between the two.
11
11
- Python 3.11.9 which can be run with the command `python3.11` and `python3`. [pyenv](https://github.com/pyenv/pyenv) is one option for getting this specific version of python and not modifying any other python installs on the system.
@@ -17,7 +17,7 @@ All requirements for running the API are packaged and uploaded to AWS as a lambd
17
17
2. Create a virtual Python environment in the `layer` directory and install the project dependencies via pip. This can be executed by running `hatch run lambda:layer-install`.
18
18
3. Package two AWS layers by executing `package-layer.sh`. This will make two files: `python3_layer_content.zip` and `mpic_coordinator_layer_content.zip` which will later be referenced by Open Tofu. This can be done by running `./package-layer.sh` or `hatch run lambda:layer-package`.
19
19
4. Run `configure.py` from the root directory of the repo to generate Open Tofu files from templates. This can be separately executed by running `hatch run ./configure.py` or `hatch run lambda:configure-tf`.
20
-
5. Zip all Lambda functions. AWS Lambda functions are usually deployed from zip files. This can be separately executed by running `./zip-all.sh` or `hatch run lambda:zip-all`.
20
+
5. Zip all Lambda functions. AWS Lambda functions are usually deployed from zip files. This can be separately executed by running `./zip-all.sh` or `hatch run lambda:zip-lambdas`.
21
21
6. Deploy the entire package with Open Tofu. cd to the `open-tofu` directory where .tf files are located. Then run `tofu init`. Then run `tofu apply` and type `yes` at the confirmation prompt. This provides a standard install with DNSSEC enabled which causes the system to incur expenses even when it is not in use (due to the AWS VPC NAT Gateways needed). To reduce the AWS bill, DNSSEC can also be disabled by appending `-var="dnssec_enabled=false"` to `tofu apply` (i.e., `tofu apply -var="dnssec_enabled=false"`).
22
22
7. Get the URL of the deployed API endpoint by running `hatch run ./get_api_url.py` in the root directory.
23
23
8. Get the API Key generated by AWS by running `hatch run ./get_api_key.py` in the root directory. The deployment is configured to reject any API call that does not have this key passed via the `x-api-key` HTTP header.
@@ -99,7 +99,7 @@ After `tofu destroy`, `./clean.sh` in the root directory also clears generated/z
99
99
100
100
## EventBridge Warmer
101
101
102
-
The AWS Lambda deployment takes approximately 8 seconds to perform the fist Open MPIC call because of [Lambda cold starts](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtime-environment.html). Subsequent calls take approximately 1 second. To avoid a cold start and get a ~1 second response time even on the first API call, the EventBridge Warmer can optionally be used to keep the Lambda functions "hot." To deploy with this feature, add `-var="eventbridge_warmer_enabled=true"` to the `tofu apply` command (e.g., `tofu apply -var="dnssec_enabled=false" -var="eventbridge_warmer_enabled=true"`). **The use of the EventBridge Warmer will increase costs and incur costs even when no API calls are being made.**
102
+
The AWS Lambda deployment takes approximately 8 seconds to perform the first Open MPIC call because of [Lambda cold starts](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtime-environment.html). Subsequent calls take approximately 1 second. To avoid a cold start and get a ~1 second response time even on the first API call, the EventBridge Warmer can optionally be used to keep the Lambda functions "hot." To deploy with this feature, add `-var="eventbridge_warmer_enabled=true"` to the `tofu apply` command (e.g., `tofu apply -var="dnssec_enabled=false" -var="eventbridge_warmer_enabled=true"`). **The use of the EventBridge Warmer will increase costs and incur costs even when no API calls are being made.**
103
103
104
104
## Additional Implementation Tasks
105
105
There are several features that may be of interest to the community, but we don't yet have a specific completion timeline. These may be given higher priority based on feedback and community interest.
0 commit comments