-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.sh
executable file
·39 lines (27 loc) · 1.21 KB
/
deploy.sh
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
#!/usr/bin/env bash
set -euo pipefail
usage(){
echo "usage ${0##*/} AWS_REGION PROMETHEUS_WORKSPACE_ID [CFN-stack-name (optional)]"
return 1
}
[ $# != 2 ] && usage
command -v aws >/dev/null 2>&1 ||
{ echo >&2 "ERR: awscli is missing, aborting!"; exit 1; }
command -v sam >/dev/null 2>&1 ||
{ echo >&2 "ERR: aws-sam is missing, aborting!"; exit 1; }
AWS_REGION=$1
PROMETHEUS_WORKSPACE_ID=$2
STACK_NAME="${3:-amp-cardinality-insights}"
echo "Deploying to AWS region ${AWS_REGION} with Prometheus workspace ID ${PROMETHEUS_WORKSPACE_ID}"
PROMETHEUS_REMOTE_WRITE_URL=$(aws --region ${AWS_REGION} amp describe-workspace \
--workspace-id ${PROMETHEUS_WORKSPACE_ID} \
--query "workspace.prometheusEndpoint" \
--output text) || { echo >&2 "ERR: Failed to get Prometheus remote write URL, aborting!"; exit 1; }
PROMETHEUS_REMOTE_WRITE_URL="${PROMETHEUS_REMOTE_WRITE_URL}api/v1/remote_write"
sed -e "s/AMP_REGION/${AWS_REGION}/g" -e "s~AMP_REMOTE_WRITE_ENDPOINT~${PROMETHEUS_REMOTE_WRITE_URL}~g" lambda/ingest-amp/collector.yaml.tpl > lambda/ingest-amp/collector.yaml
cd lambda
sam build
sam sync --stack-name $STACK_NAME \
--parameter-overrides WorkspaceId=${PROMETHEUS_WORKSPACE_ID} \
--no-watch
cd -