Skip to content

Commit

Permalink
Add '-l' to rds shell script for feature parity with aurora shell script
Browse files Browse the repository at this point in the history
  • Loading branch information
DrizzlyOwl committed Mar 1, 2024
1 parent ac60860 commit 065d1c2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion bin/aurora/shell
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ usage() {
echo " -i <infrastructure> - infrastructure name"
echo " -r <aurora_name> - RDS name (as defined in the Dalmatian config)"
echo " -e <environment> - environment name (e.g. 'staging' or 'prod')"
echo " -l - list available ec2 instance ids (optional)"
echo " -I <ecs_instance_id> - ECS instance ID to connect through (optional)"
exit 1
}
Expand All @@ -20,7 +21,7 @@ then
usage
fi

while getopts "i:e:r:I:h" opt; do
while getopts "i:e:r:I:lh" opt; do
case $opt in
i)
INFRASTRUCTURE_NAME=$OPTARG
Expand All @@ -34,6 +35,9 @@ while getopts "i:e:r:I:h" opt; do
I)
ECS_INSTANCE_ID=$OPTARG
;;
l)
LIST=1
;;
h)
usage
;;
Expand All @@ -51,6 +55,16 @@ if [[
usage
fi

if [ -n "$LIST" ];
then
echo "==> Finding ECS instances..."
INSTANCES=$(aws ec2 describe-instances --filters Name=instance-state-code,Values=16 Name=tag:Name,Values="$INFRASTRUCTURE_NAME-$ENVIRONMENT*")

AVAILABLE_INSTANCES=$(echo "$INSTANCES" | jq -r '.Reservations[].Instances[] | (.InstanceId) + " | " + (.Tags[] | select(.Key == "Name") | .Value) + " | " + (.LaunchTime)')
echo "$AVAILABLE_INSTANCES"
exit 0
fi

# Remove dashes from the variables to create the RDS identifier, because dashes
# aren't allowed in RDS identifiers. Dalmatian removes them on deployment, so we
# need to remove them here to get the correct identifier.
Expand Down

0 comments on commit 065d1c2

Please sign in to comment.