Skip to content

Commit 3581865

Browse files
committed
allow for a cluster endpoint override argument
1 parent 685ab70 commit 3581865

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

bin/docdb-3.6-connect.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ LOCAL_PORT=27017
1111
SSM_PID=""
1212

1313
function usage {
14-
echo "usage: $(basename "$0") app_name"
14+
echo "usage: $(basename "$0") app_name [db_endpoint:port]"
1515
exit 1
1616
}
1717

1818
APP_NAME=${1:-}
19+
DB_ENDPOINT_OVERRIDE=${2:-}
1920

2021
if [[ -z $APP_NAME ]]; then
2122
usage
@@ -50,9 +51,13 @@ if [[ -z $BASTION_INSTANCE_ID || $BASTION_INSTANCE_ID == "None" ]]; then
5051
exit 1
5152
fi
5253

53-
DB_ENDPOINT_WITH_PORT=$(aws cloudformation list-exports \
54-
--query "Exports[?Name=='${STACK_NAME}-db-cluster-endpoint'].Value" \
55-
--output text)
54+
if [[ -n $DB_ENDPOINT_OVERRIDE ]]; then
55+
DB_ENDPOINT_WITH_PORT=$DB_ENDPOINT_OVERRIDE
56+
else
57+
DB_ENDPOINT_WITH_PORT=$(aws cloudformation list-exports \
58+
--query "Exports[?Name=='${STACK_NAME}-db-cluster-endpoint'].Value" \
59+
--output text)
60+
fi
5661

5762
if [[ -z $DB_ENDPOINT_WITH_PORT || $DB_ENDPOINT_WITH_PORT == "None" ]]; then
5863
echo "Error: could not find db endpoint export for ${STACK_NAME}" >&2

0 commit comments

Comments
 (0)