forked from UBC-CIC/vch-mri
-
Notifications
You must be signed in to change notification settings - Fork 0
/
amplify.yml
48 lines (46 loc) · 2.47 KB
/
amplify.yml
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
45
46
47
version: 1
backend:
phases:
preBuild:
commands:
- npm install -g @aws-amplify/cli
build:
commands:
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple
postBuild:
commands:
- yum install -y jq
- export AWS_REGION=$(aws configure get region)
- export ACCOUNTID=$(aws sts get-caller-identity --query Account --output text)
- export PROJECT_NAME=$(cat ./amplify/.config/project-config.json | jq -r '.projectName')
- export S3_BUCKET=$(aws resourcegroupstaggingapi get-resources --tag-filters Key=user:Application,Values="${PROJECT_NAME}" --resource-type-filters s3 --query 'ResourceTagMappingList[*].[ResourceARN]' --output text | grep -v deployment | awk -F':::' '{print $2}')
- export LAMBDA_ARN=$(aws ssm get-parameter --name /mri-sched/lambdathesaurusarn --query Parameter.Value --output text)
- export LAMBDA_NAME=$(echo $LAMBDA_ARN | awk -F':' '{print $7}')
- export S3INVOKE=$(aws lambda get-policy --function-name $LAMBDA_NAME | grep s3invoke | wc -l)
- if [ $S3INVOKE -eq 1 ]; then aws lambda remove-permission --function-name ${LAMBDA_NAME} --statement-id s3invoke; fi
- aws lambda add-permission --function-name ${LAMBDA_NAME} --principal s3.amazonaws.com --statement-id s3invoke --action "lambda:InvokeFunction" --source-arn arn:aws:s3:::${S3_BUCKET} --source-account ${ACCOUNTID}
- sed "s|%LambdaArn%|$LAMBDA_ARN|g" notification.json > notification.s3
- aws s3api put-bucket-notification-configuration --bucket $S3_BUCKET --notification-configuration file://notification.s3 --output text
- aws s3 cp ./src/backend/csv/thesaurus_medical.ths s3://$S3_BUCKET/public/thesaurus_medical.ths
- export LAMBDA_UPDATE=$(aws ssm get-parameter --name /mri-sched/lambdaupdateweightsarn --query Parameter.Value --output text)
- aws lambda invoke --function-name $LAMBDA_UPDATE response.json
frontend:
phases:
preBuild:
commands:
- cd src/frontend
- npm install
build:
commands:
- export API_ID=$(aws ssm get-parameter --name /mri-sched/apiid --query Parameter.Value --output text)
- export AWS_REGION=$(aws configure get region)
- export REACT_APP_HTTP_API_URL="https://${API_ID}.execute-api.${AWS_REGION}.amazonaws.com"
- npm run build
artifacts:
baseDirectory: src/frontend/build
files:
- '**/*'
cache:
paths:
- node_modules/**/*