Skip to content

Commit 1aae716

Browse files
chore: add make commands to package and clean zip (#885)
* add make cmds to package and clean zip Signed-off-by: Kavindu Dodanduwa <[email protected]> * build with x86_64 deps and bump es apm to support python 12 Signed-off-by: Kavindu Dodanduwa <[email protected]> * document build options Signed-off-by: Kavindu Dodanduwa <[email protected]> --------- Signed-off-by: Kavindu Dodanduwa <[email protected]>
1 parent 3c41a9d commit 1aae716

File tree

3 files changed

+42
-8
lines changed

3 files changed

+42
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*.egg
66
*.db
77
*.pid
8+
*.zip
89
.coverage*
910
.DS_Store
1011
.idea

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ isort: ## Run isort in the project on the host
3636
mypy: ## Run mypy in the project on the host
3737
tests/scripts/${SCRIPTS_BASE_DIR}mypy.sh
3838

39+
package: ## Package lambda by installing python dependencies matching x86_64
40+
mkdir deps && \
41+
pip install --target=./deps --platform manylinux2014_x86_64 --implementation cp --python-version 3.12 --only-binary=:all: --upgrade -r requirements.txt && \
42+
cd ./deps && \
43+
zip -r ../local_esf.zip . && \
44+
cd .. && \
45+
zip -r local_esf.zip main_aws.py handlers share storage shippers && \
46+
rm -r ./deps
47+
48+
clean: ## cleanup any leftover resources
49+
rm -f -r ./deps
50+
rm -f local_esf.zip
51+
3952
docker-test: ## Run all tests on docker
4053
docker-test: SCRIPTS_BASE_DIR=docker/
4154
docker-test: test

dev-corner/how-to-test-locally/README.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
1-
This is just an example of how to build and run ESF locally.
1+
This document contains details about how to build ESF Lambda locally.
2+
Once built, the Lambda can be deployed to validate functionality.
23

3-
## Requirements
4+
## Building lambda
5+
6+
To build the Lambda, you may use one of the options below,
7+
8+
### Using Makefile
9+
10+
To build,
11+
12+
```shell
13+
make package
14+
```
15+
16+
This will generate a Lambda zip named `local_esf.zip`.
17+
18+
To clean up any leftover resources,
19+
20+
```shell
21+
make clean
22+
```
23+
24+
### Using Task file
25+
26+
#### Requirements
427

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

831

9-
## Steps
32+
#### Building
1033

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

13-
### Step 1: Build your dependencies zip file
14-
1536
You can build your own, or you can choose to run:
1637
```bash
1738
task
@@ -24,13 +45,12 @@ You can update the task variables in the `.env` file:
2445
- The name of the zip file, `FILENAME`.
2546

2647

27-
### Step 2: Run ESF terraform
48+
## Deploying Lambda
2849

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

3152
> **NOTE**: ESF lambda function is using architecture `x86_64`.
3253
33-
3454
Place your `local_esf.zip` (or `<FILENAME>` if you changed the value) in the same directory as ESF terraform.
3555

3656
Go to `esf.tf` file and edit:

0 commit comments

Comments
 (0)