elastalert-lambda/Makefile

46 lines
1.3 KiB
Makefile

PY_VERSION := 2.7
PACKAGE_NAME := elastalert_lambda
VERSION ?= $(shell grep '__version__' $(PACKAGE_NAME).py | cut -d' ' -f3 | cut -d'-' -f1 | sed -e 's/"//g')
S3_BUCKETS ?= zero-downtime.us-west-2
S3_PREFIX ?= cloudbender/$(PACKAGE_NAME)
PACKAGE := $(PACKAGE_NAME)-$(VERSION).zip
PACKAGE_FILE := dist/$(PACKAGE)
.PHONY: test clean build all upload clean_s3
all: test build
test:
flake8 --ignore=E501 . tests
TEST=True pytest --log-cli-level=DEBUG
clean:
rm -rf __pycache__ .cache .coverage .pytest_cache dist prof *.pyc
build: $(PACKAGE_FILE)
$(PACKAGE_FILE):
rm -rf dist && mkdir dist
cp -r $(PACKAGE_NAME).py elastalert_rules.py config.yaml dist/
pip$(PY_VERSION) install --target dist --no-compile elastalert
# Hack to remove ES >=7 and reinstall 6.3.1
rm -rf dist/elasticsearch*
pip$(PY_VERSION) install --target dist --no-compile elasticsearch==6.3.1
cd dist && zip -q -r $(PACKAGE) *
upload: $(PACKAGE_FILE)
for bucket in $(S3_BUCKETS); do \
aws s3 cp --acl public-read $(PACKAGE_FILE) s3://$$bucket/$(S3_PREFIX)/latest.zip; \
aws s3 cp --acl public-read $(PACKAGE_FILE) s3://$$bucket/$(S3_PREFIX)/$(PACKAGE); \
done
clean_s3:
for bucket in $(S3_BUCKETS); do \
aws s3 rm --recursive --exclude "*" --include latest.zip --include $(PACKAGE_NAME)-*.zip s3://$$bucket/$(S3_PREFIX); \
done