-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
32 lines (29 loc) · 1.07 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
AWS_PROFILE := default
AWS_REGION := ap-northeast-1
AWS_ACCOUNT_ID := $(shell aws --profile $(AWS_PROFILE) sts get-caller-identity --query Account --output text)
PYTHON_VERSION := 3.11
PIP_COMAND := pip$(PYTHON_VERSION)
ARCHITECTURE := arm64
PLATFORM := linux/$(ARCHITECTURE)
LAYER_NAME := psycopg2-binary-$(PYTHON_VERSION)-$(ARCHITECTURE)
CONTAINER_IMAGE := public.ecr.aws/lambda/python:$(PYTHON_VERSION)
.PHONY: push deploy
build:
docker run --rm \
--platform=$(PLATFORM) \
-v $(PWD):/work \
-w /work \
--entrypoint $(PIP_COMAND) \
$(CONTAINER_IMAGE) \
install -r requirements.txt -t python
find python/ -name '__pycache__' -type d -delete
zip -r layer.zip python/
unzip -l layer.zip
deploy: build
aws --profile $(AWS_PROFILE) --region $(AWS_REGION) \
lambda publish-layer-version --layer-name $(subst .,-,$(LAYER_NAME)) \
--description "psycopg2-binary $(PYTHON_VERSION) $(ARCHITECTURE)" \
--zip-file fileb://layer.zip \
--compatible-runtimes python$(PYTHON_VERSION) \
--compatible-architectures $(subst amd64,x86_64,$(ARCHITECTURE))
rm -rf python/ layer.zip