From 7de2e0bc1d8554d14cca49db3c340bcea6abc10e Mon Sep 17 00:00:00 2001 From: Deepak Jagannath Date: Sat, 27 Jul 2019 12:44:54 -0700 Subject: [PATCH] Add put config script. This doesn't work because the Cloudformation script doesn't export the DynamoDB tables. Add Pagerduty schedule ID/slack ID manually to the DynamoDB talbe for now. --- scripts/put-config.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 scripts/put-config.sh diff --git a/scripts/put-config.sh b/scripts/put-config.sh new file mode 100755 index 0000000..18cb8ef --- /dev/null +++ b/scripts/put-config.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + + # Quick script to assist with dynamodb config +STACKNAME_BASE=$(grep -E -o -m 1 '"([^"]*)"' ./Makefile | sed 's/"//g') +TABLE_NAME=$(aws cloudformation list-exports |grep -E -o "$STACKNAME_BASE-ConfigTable-.*?" | sed 's/",//g') + +read -sp "Pagerduty schedule ID (PXXXXX): " schedule; echo +read -sp "Slack channel (CXXXXXXXX): " slack; echo + + # build dynamodb json. variable handling makes it janky +read -r -d '' TABLE_ITEM << EOM +{ + "schedule": "$schedule", + "slack": "$slack" +} +EOM +echo $STACKNAME_BASE +echo $TABLE_ITEM + + # update dynamodb table +aws dynamodb put-item --table-name $TABLE_NAME --item "$TABLE_ITEM" \ No newline at end of file