Skip to content

Commit 9045441

Browse files
Merge pull request #5 from abk7777/refactor/local-makefiles
Add Lambda trigger, refactor by service using Makefiles, add SSM and Secrets
2 parents 4216ffd + 689c561 commit 9045441

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+888
-762
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ _M*
9494
_*.yaml
9595
_*.json
9696
logs.txt
97-
config/
9897
logs/
9998
0.1-gfe-sandbox.ipynb
10099
0.1-dev-build-graph.ipynb
@@ -106,4 +105,7 @@ build/Makefile
106105
load/Makefile
107106
.aws-sam
108107
packaged.yaml
109-
samconfig.toml
108+
samconfig.toml
109+
scripts/
110+
cfn/
111+
_pr.md

Makefile

Lines changed: 80 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,105 @@
11
##########################
22
# Bootstrapping variables
33
##########################
4-
5-
# TODO: move to config file and parse with jq, or use SSM parameter store
64
export STAGE ?= dev
75
export APP_NAME ?= gfe-db
8-
export NEO4J_USERNAME ?= neo4j
9-
export NEO4J_PASSWORD ?= gfedb
6+
export AWS_ACCOUNT ?= $(shell aws sts get-caller-identity --query Account --output text)
107
export REGION ?= us-east-1
118

9+
export DATA_BUCKET_NAME ?= ${STAGE}-${APP_NAME}-${AWS_ACCOUNT}-${REGION}
10+
export ECR_BASE_URI ?= ${AWS_ACCOUNT}.dkr.ecr.${REGION}.amazonaws.com
11+
export BUILD_REPOSITORY ?= ${STAGE}-${APP_NAME}-build-service
12+
export LOAD_REPOSITORY ?= ${STAGE}-${APP_NAME}-load-service
13+
1214
target:
1315
$(info ${HELP_MESSAGE})
1416
@exit 0
1517

16-
17-
deploy: deploy.cfn deploy.ecr
18-
19-
deploy.ecr:
20-
$(info [*] Logging into ECR...)
21-
@aws ecr get-login-password \
22-
--region ${REGION} | docker login \
23-
--username AWS \
24-
--password-stdin $$(aws sts get-caller-identity --query Account --output text).dkr.ecr.${REGION}.amazonaws.com
25-
26-
# # @$(info [*] Pushing build service image to ECR...)
27-
@docker build -t ${STAGE}-${APP_NAME}-build-service build/ && \
28-
docker tag ${STAGE}-${APP_NAME}-build-service:latest $$(aws sts get-caller-identity --query Account --output text).dkr.ecr.${REGION}.amazonaws.com/${STAGE}-${APP_NAME}-build-service:latest && \
29-
docker push $$(aws sts get-caller-identity --query Account --output text).dkr.ecr.${REGION}.amazonaws.com/${STAGE}-${APP_NAME}-build-service:latest
30-
31-
# # @$(info [*] Pushing load service image to ECR...)
32-
@docker build -t ${STAGE}-${APP_NAME}-load-service load/ && \
33-
docker tag ${STAGE}-${APP_NAME}-load-service:latest $$(aws sts get-caller-identity --query Account --output text).dkr.ecr.${REGION}.amazonaws.com/${STAGE}-${APP_NAME}-load-service:latest && \
34-
docker push $$(aws sts get-caller-identity --query Account --output text).dkr.ecr.${REGION}.amazonaws.com/${STAGE}-${APP_NAME}-load-service:latest
35-
36-
deploy.cfn:
37-
$(info [*] Deploying...)
38-
@bash scripts/deploy.sh ${STAGE} ${APP_NAME} ${REGION} ${NEO4J_USERNAME} ${NEO4J_PASSWORD}
39-
40-
run: ##=> Load an IMGT/HLA release version; make run release=3450 align=False kir=False mem_profile=False limit=1000
41-
$(info [*] Starting StepFunctions execution for release $(release))
42-
43-
# @# TODO: Add validation for positional arguments: release, align, kir, mem_profile, limit
44-
@echo "Execution running:"
45-
@aws stepfunctions start-execution \
46-
--state-machine-arn $$(aws ssm get-parameter --name "/${APP_NAME}/${STAGE}/${REGION}/UpdatePipelineArn" | jq -r '.Parameter.Value') \
47-
--input "{\"params\":{\"environment\":{\"RELEASES\":\"$(release)\",\"ALIGN\":\"False\",\"KIR\":\"False\",\"MEM_PROFILE\":\"False\",\"LIMIT\":\"$(limit)\"}}}" | jq '.executionArn'
48-
49-
delete: ##=> Delete resources
50-
$(info [*] Deleting resources...)
51-
@bash scripts/delete.sh ${STAGE} ${APP_NAME} ${REGION}
18+
deploy: check-env ##=> Deploy services
19+
$(info [*] Deploying ${APP_NAME} to ${AWS_ACCOUNT}...)
20+
$(MAKE) deploy.infrastructure
21+
$(MAKE) deploy.database
22+
$(MAKE) deploy.pipeline
23+
@echo "Finished deploying ${APP_NAME}."
24+
25+
check-env:
26+
ifndef AWS_PROFILE
27+
$(error AWS_PROFILE is not set. Please select an AWS profile to use.)
28+
endif
29+
ifndef NEO4J_USERNAME
30+
$(error NEO4J_USERNAME is not set.)
31+
endif
32+
ifndef NEO4J_PASSWORD
33+
$(error NEO4J_PASSWORD is not set.)
34+
endif
35+
ifndef GITHUB_PERSONAL_ACCESS_TOKEN
36+
$(error GITHUB_PERSONAL_ACCESS_TOKEN is not set.)
37+
endif
38+
@echo "Found environment variables"
39+
40+
# Deploy specific stacks
41+
deploy.infrastructure:
42+
$(MAKE) -C gfe-db/infrastructure/ deploy
43+
44+
deploy.database:
45+
$(MAKE) -C gfe-db/database/ deploy
46+
47+
deploy.pipeline:
48+
$(MAKE) -C gfe-db/pipeline/ deploy
49+
50+
delete: ##=> Delete services
51+
$(info [*] Deleting ${APP_NAME} in ${AWS_ACCOUNT}...)
52+
$(MAKE) delete.pipeline
53+
$(MAKE) delete.database
54+
$(MAKE) delete.infrastructure
55+
@echo "Finished deleting ${APP_NAME}."
56+
57+
# Delete specific stacks
58+
delete.infrastructure:
59+
$(MAKE) -C gfe-db/infrastructure/ delete
60+
61+
delete.database:
62+
$(MAKE) -C gfe-db/database/ delete
63+
64+
delete.pipeline:
65+
$(MAKE) -C gfe-db/pipeline/ delete
66+
67+
# run: ##=> Load an IMGT/HLA release version; make run release=3450 align=False kir=False mem_profile=False limit=1000
68+
# $(info [*] Starting StepFunctions execution for release $(release))
69+
70+
# # @# TODO: Add validation for positional arguments: release, align, kir, mem_profile, limit
71+
# @echo "Execution running:"
72+
# @aws stepfunctions start-execution \
73+
# --state-machine-arn $$(aws ssm get-parameter --name "/${APP_NAME}/${STAGE}/${REGION}/UpdatePipelineArn" | jq -r '.Parameter.Value') \
74+
# --input "{\"params\":{\"environment\":{\"RELEASES\":\"$(release)\",\"ALIGN\":\"False\",\"KIR\":\"False\",\"MEM_PROFILE\":\"False\",\"LIMIT\":\"$(limit)\"}}}" | jq '.executionArn'
5275

5376
define HELP_MESSAGE
5477

5578
Environment variables:
5679

5780
STAGE: "${STAGE}"
5881
Description: Feature branch name used as part of stacks name
82+
5983
APP_NAME: "${APP_NAME}"
6084
Description: Stack Name already deployed
85+
86+
AWS_ACCOUNT: "${AWS_ACCOUNT}":
87+
Description: AWS account ID for deployment
88+
6189
REGION: "${REGION}":
6290
Description: AWS region for deployment
63-
NEO4J_USERNAME: "${NEO4J_USERNAME}"
64-
Description: Neo4j username
65-
NEO4J_PASSWORD: "${NEO4J_PASSWORD}"
66-
Description: Neo4j password
91+
92+
DATA_BUCKET_NAME "$${DATA_BUCKET_NAME}"
93+
Description: Name of the S3 bucket for data, config and logs
94+
95+
ECR_BASE_URI: "$${ECR_BASE_URI}"
96+
Description: Base URI for AWS Elastic Container Registry
97+
98+
BUILD_REPOSITORY: "$${BUILD_REPOSITORY}"
99+
Description: Name of the ECR repository for the build service
100+
101+
LOAD_REPOSITORY: "$${LOAD_REPOSITORY}"
102+
Description: Name of the ECR repository for the load service
67103

68104
Common usage:
69105

0 commit comments

Comments
 (0)