-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
44 lines (34 loc) · 1.04 KB
/
Makefile
File metadata and controls
44 lines (34 loc) · 1.04 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
# Configuration
PROJECT_DIR := $(shell pwd)
AWS_REGION := us-west-2
API_TOKEN := $(shell yq .token ${HOME}/.replicated/config.yaml)
SRC_DIR := $(PROJECT_DIR)/src
BUILD_DIR := $(PROJECT_DIR)/build
DEPLOY_DIR := $(PROJECT_DIR)/deploy
TERRAFORM_DIR := $(DEPLOY_DIR)/terraform
TF_FLAGS := -var="build_directory=$(BUILD_DIR)" -var "aws_region=$(AWS_REGION)" -var "api_token=$(API_TOKEN)" -var "owner=${USER}"
.PHONY: prepare package deploy clean
# Default target
all: deploy
# prepare the build directory
prepare:
@mkdir -p $(BUILD_DIR)
@cp -r $(SRC_DIR)/* ${BUILD_DIR}
# Package Lambda function
package: prepare
cd $(BUILD_DIR)/create-license && \
pip install -r requirements.txt -t . --upgrade && \
zip -r ${BUILD_DIR}/create-license.zip .
# Deploy with Terraform
plan: package
cd $(TERRAFORM_DIR) && \
terraform init && \
terraform plan $(TF_FLAGS)
# Deploy with Terraform
deploy: package
cd $(TERRAFORM_DIR) && \
terraform init && \
terraform apply $(TF_FLAGS) -auto-approve
# Clean up the package
clean:
rm -rf $(BUILD_DIR)/*