Skip to content

Commit

Permalink
update lib
Browse files Browse the repository at this point in the history
  • Loading branch information
gdbtek committed May 19, 2020
1 parent 2e124de commit d2af295
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions libraries/aws.bash
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,31 @@ function getEC2ElasticAllocationIDByElasticPublicIP()
2> '/dev/null'
}

function getEC2ElasticAssociationIDByElasticPublicIP()
{
local -r elasticPublicIP="${1}"
local region="${3}"

# Set Default Value

if [[ "$(isEmptyString "${region}")" = 'true' ]]
then
region="$(getInstanceRegion 'false')"
fi

checkNonEmptyString "${elasticPublicIP}" 'undefined elastic public ip'

# Get EC2 Elastic Association ID

aws ec2 describe-addresses \
--output 'text' \
--public-ips "${elasticPublicIP}" \
--query 'Addresses[0].[AssociationId]' \
--region "${region}" \
2> '/dev/null' |
grep -i -v '^None$'
}

function getEC2PrivateIpAddressByInstanceID()
{
local -r instanceID="${1}"
Expand Down

0 comments on commit d2af295

Please sign in to comment.