|
1 | 1 | ########################## |
2 | 2 | # Bootstrapping variables |
3 | 3 | ########################## |
4 | | - |
5 | | -# TODO: move to config file and parse with jq, or use SSM parameter store |
6 | 4 | export STAGE ?= dev |
7 | 5 | 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) |
10 | 7 | export REGION ?= us-east-1 |
11 | 8 |
|
| 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 | + |
12 | 14 | target: |
13 | 15 | $(info ${HELP_MESSAGE}) |
14 | 16 | @exit 0 |
15 | 17 |
|
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' |
52 | 75 |
|
53 | 76 | define HELP_MESSAGE |
54 | 77 |
|
55 | 78 | Environment variables: |
56 | 79 |
|
57 | 80 | STAGE: "${STAGE}" |
58 | 81 | Description: Feature branch name used as part of stacks name |
| 82 | + |
59 | 83 | APP_NAME: "${APP_NAME}" |
60 | 84 | Description: Stack Name already deployed |
| 85 | + |
| 86 | + AWS_ACCOUNT: "${AWS_ACCOUNT}": |
| 87 | + Description: AWS account ID for deployment |
| 88 | + |
61 | 89 | REGION: "${REGION}": |
62 | 90 | 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 |
67 | 103 |
|
68 | 104 | Common usage: |
69 | 105 |
|
|
0 commit comments