🛌 Commit progress before sleep break

This commit is contained in:
steinkirch.eth, phd 2023-07-14 21:50:31 -07:00
parent 119cc7f62c
commit 585ee80f5d
319 changed files with 29 additions and 23 deletions

View file

@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -o errexit # always exit on error
set -o errtrace # trap errors in functions as well
set -o pipefail # don't ignore exit codes when piping output
IFS=$'\n\t'
cd "$(dirname "${BASH_SOURCE[0]}")/.."
source "$1"
make --makefile=./scripts/deploy.mk all

View file

@ -0,0 +1,30 @@
SAM_INPUT_TEMPLATE=./src/template.yaml
SAM_OUTPUT_TEMPLATE=./src/packaged-template.yaml
.PHONY: validate-env
validate-env:
@./scripts/validate-env.sh \
AWS_ACCESS_KEY_ID \
AWS_REGION \
AWS_SECRET_ACCESS_KEY \
STACK_NAME \
S3_BUCKET
.PHONY: package
package: validate-env
@aws cloudformation package \
--template-file ${SAM_INPUT_TEMPLATE} \
--output-template-file ${SAM_OUTPUT_TEMPLATE} \
--s3-bucket ${S3_BUCKET} \
--region ${AWS_REGION}
.PHONY: deploy
deploy: validate-env package
aws cloudformation deploy \
--template-file ${SAM_OUTPUT_TEMPLATE} \
--stack-name ${SAM_STACK_NAME} \
--capabilities CAPABILITY_IAM \
--region ${AWS_REGION}
.PHONY: all
all: deploy

View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -o errexit # always exit on error
set -o errtrace # trap errors in functions as well
set -o pipefail # don't ignore exit codes when piping output
set -o posix # more strict failures in subshells
IFS=$'\n\t'
##### RUNNING THE SCRIPT #####
# export FUNCTION = <name of the lambda function in aws, can be found by aws lambda list-functions"
# source .env
# ./scripts/invoke.sh {true|false} [count]
cd "$(dirname "${BASH_SOURCE[0]}")/.."
./scripts/validate-env.sh AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY
function=$(aws lambda list-functions | jq -r '.Functions[].FunctionName' | grep -E '^monitoring-lambda' | head -1)
payload="{\"forceError\": ${1:-false}}"
outpath="/tmp/monitoring-lambda.out"
count="${2:-1}"
for i in $(seq "${count}"); do
aws lambda invoke \
--function-name "${function}" \
--invocation-type Event \
--payload "${payload}" \
"${outpath}"
done

View file

@ -0,0 +1 @@
sam logs -n REPLACE-LOGS-NAME --stack-name REPLACE-STACK-NAME -t

View file

@ -0,0 +1 @@
sam package --template-file template.yaml --output-template-file packaged.yaml --s3-bucket s3-test-deployment

View file

@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -o errexit # always exit on error
set -o errtrace # trap errors in functions as well
set -o pipefail # don't ignore exit codes when piping output
set -o posix # more strict failures in subshells
IFS=$'\n\t'
declare -a missing
for var in "$@"; do
if [[ -z "${!var}" ]]; then
echo "⚠️ ERROR: Missing required environment variable: ${var}" 1>&2
missing+=("${var}")
fi
done
if [[ -n "${missing[*]}" ]]; then
exit 1
fi