Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gdbtek committed Sep 29, 2017
1 parent 6322378 commit 8cf15d1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions libraries/aws.bash
Original file line number Diff line number Diff line change
Expand Up @@ -580,26 +580,34 @@ 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$'
}

function getSubnetIDsByNames()
{
local -r subnetNames=("${@}")
local -r vpcName="${1}"
local -r subnetNames=("${@:2}")

local subnetID=''
local subnetIDs=''
local subnetName=''

for subnetName in "${subnetNames[@]}"
do
subnetID="$(getSubnetIDByName "${subnetName}")"
subnetID="$(getSubnetIDByName "${vpcName}" "${subnetName}")"

checkNonEmptyString "${subnetID}" "subnet name '${subnetName}' not found"

Expand Down

0 comments on commit 8cf15d1

Please sign in to comment.