-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.yml
45 lines (40 loc) · 1.78 KB
/
buildspec.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
version: 0.2
env:
variables:
REGION: "us-east-1"
TEST_HOST: "Uruguay"
phases:
install:
runtime-versions:
python: 3.9
commands:
- python3 -m pip install --upgrade pip
pre_build:
commands:
- echo pre-build started
- aws --version
- sam --version
build:
commands:
- cd $CODEBUILD_SRC_DIR
- sam build
- "sam deploy --config-env development --resolve-s3 --no-confirm-changeset || :"
# Obtain Main Env Vars
- eval $(aws cloudformation describe-stack-resources --stack-name serverless-wc-data --region $REGION --query "StackResources[*].[LogicalResourceId, PhysicalResourceId]" --output text | awk '{print "export "$1"="$2}')
# Obtain API KEY
- aws apigateway get-usage-plan-key --key-id $ApiKey --usage-plan-id $usagePlan --region $REGION
- eval $(aws apigateway get-usage-plan-key --key-id $ApiKey --usage-plan-id $usagePlan --region $REGION --query 'value' --output text | awk '{print "export X_API_KEY="$1}')
# Obtaining URL
- export URL="https://$TheWorldCupApi.execute-api.$REGION.amazonaws.com/$TheWorldCupApiProdStage/world-cup"
post_build:
commands:
- echo "Obtain URL_QUEUE"
- URL_QUEUE=$(aws sqs list-queues --queue-name-prefix WCP --query 'QueueUrls[0]' --output text)
- cd $CODEBUILD_SRC_DIR/data
- echo "Sending historical data to the Simple Queue Service"
- for FILE in $(ls -1 *.json); do FILE_CONTENT=$(cat $FILE); aws sqs send-message --queue-url $URL_QUEUE --message-body "$FILE_CONTENT"; done
- echo "Preparing simple test to send a GET request"
- sleep 20
- echo "Simple test, consulting WC Data from $TEST_HOST"
# Simple Test
- "curl -H \"Content-type:json\" -H \"x-api-key: $X_API_KEY\" \"$URL?host=$TEST_HOST\""