Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.egg
*.db
*.pid
*.zip
.coverage*
.DS_Store
.idea
Expand Down
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ isort: ## Run isort in the project on the host
mypy: ## Run mypy in the project on the host
tests/scripts/${SCRIPTS_BASE_DIR}mypy.sh

package: ## Package lambda by installing python dependencies matching x86_64
mkdir deps && \
pip install --target=./deps --platform manylinux2014_x86_64 --implementation cp --python-version 3.12 --only-binary=:all: --upgrade -r requirements.txt && \
cd ./deps && \
zip -r ../local_esf.zip . && \
cd .. && \
zip -r local_esf.zip main_aws.py handlers share storage shippers && \
rm -r ./deps

clean: ## cleanup any leftover resources
rm -f -r ./deps
rm -f local_esf.zip

docker-test: ## Run all tests on docker
docker-test: SCRIPTS_BASE_DIR=docker/
docker-test: test
Expand Down
36 changes: 28 additions & 8 deletions dev-corner/how-to-test-locally/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
This is just an example of how to build and run ESF locally.
This document contains details about how to build ESF Lambda locally.
Once built, the Lambda can be deployed to validate functionality.

## Requirements
## Building lambda

To build the Lambda, you may use one of the options below,

### Using Makefile

To build,

```shell
make package
```

This will generate a Lambda zip named `local_esf.zip`.

To clean up any leftover resources,

```shell
make clean
```

### Using Task file

#### Requirements

- [Terraform](https://www.terraform.io/)
- (Optional) [Taskfile](https://taskfile.dev/installation/)


## Steps
#### Building

**Important note**: ESF dependencies have been tested on architecture `x86_64`. Make sure to use it as well.

### Step 1: Build your dependencies zip file

You can build your own, or you can choose to run:
```bash
task
Expand All @@ -24,13 +45,12 @@ You can update the task variables in the `.env` file:
- The name of the zip file, `FILENAME`.


### Step 2: Run ESF terraform
## Deploying Lambda

Use the code in [ESF terraform repository](https://github.com/elastic/terraform-elastic-esf).
Once Lambda zip is ready, you should use the code in [ESF terraform repository](https://github.com/elastic/terraform-elastic-esf).

> **NOTE**: ESF lambda function is using architecture `x86_64`.


Place your `local_esf.zip` (or `<FILENAME>` if you changed the value) in the same directory as ESF terraform.

Go to `esf.tf` file and edit:
Expand Down