From 8cf15d1837424bbe56e09e5b0e10c69f8ca578c3 Mon Sep 17 00:00:00 2001 From: gdbtek Date: Thu, 28 Sep 2017 21:05:06 -0700 Subject: [PATCH] bug fixes --- libraries/aws.bash | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libraries/aws.bash b/libraries/aws.bash index 94c40842..06124185 100644 --- a/libraries/aws.bash +++ b/libraries/aws.bash @@ -580,10 +580,17 @@ function getPublicElasticIPs() function getSubnetIDByName() { - local -r subnetName="${1}" + local -r vpcName="${1}" + local -r subnetName="${2}" + + local -r vpcID="$(getVPCIDByName "${vpcName}")" + + checkNonEmptyString "${vpcID}" 'undefined VPC ID' aws ec2 describe-subnets \ - --filter "Name=tag:Name,Values=${subnetName}" \ + --filter \ + "Name=tag:Name,Values=${subnetName}" \ + "Name=vpc-id,Values=${vpcID}" \ --output 'text' \ --query 'Subnets[0].[SubnetId]' | grep -E -v '^None$' @@ -591,7 +598,8 @@ function getSubnetIDByName() function getSubnetIDsByNames() { - local -r subnetNames=("${@}") + local -r vpcName="${1}" + local -r subnetNames=("${@:2}") local subnetID='' local subnetIDs='' @@ -599,7 +607,7 @@ function getSubnetIDsByNames() for subnetName in "${subnetNames[@]}" do - subnetID="$(getSubnetIDByName "${subnetName}")" + subnetID="$(getSubnetIDByName "${vpcName}" "${subnetName}")" checkNonEmptyString "${subnetID}" "subnet name '${subnetName}' not found"