-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
40 lines (32 loc) · 1.16 KB
/
makefile
File metadata and controls
40 lines (32 loc) · 1.16 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
.PHONY: init terraform localstack zip shutdown clean invoke
LS_API_GW_URL = http://localhost:4566/restapis
GATEWAY_ID_OUTPUT_NAME := api_gateway_id
localstack:
@docker-compose up -d
build:
@echo "Building Go Lambda function..."
@cd src/lambda && CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o bootstrap main.go
@echo "Creating zip file..."
@cd src/lambda && zip ../../terraform/bootstrap.zip bootstrap
@cd src/lambda && rm bootstrap
@echo "Lambda zip file created at terraform/bootstrap.zip"
terraform:
@tflocal -chdir=terraform init
@tflocal -chdir=terraform apply --auto-approve
init: localstack build terraform
@echo "Initialisation complete"
@echo "Run 'make invoke' to trigger lambda"
invoke:
@API_ID=$$(tflocal -chdir=terraform output -raw $(GATEWAY_ID_OUTPUT_NAME)) && \
curl -X POST $(LS_API_GW_URL)/$$API_ID/v1/_user_request_/test
clean:
@rm -rf terraform/.terraform
@rm -rf terraform/builds
@rm -f terraform/.terraform.lock.hcl
@rm -f terraform/bootstrap.zip
@rm -f terraform/terraform.tfstate
@rm -f terraform/terraform.tfstate.backup
@echo "Cleaned build artifacts"
shutdown: clean
@echo "Shutting down localstack..."
@docker-compose down