-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into tg-tfvars-function
- Loading branch information
Showing
5 changed files
with
151 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Usage: | ||
# . drain_pool.sh <pool_id> | ||
|
||
# This script will remove and release all but one number from a Pinpoint pool | ||
|
||
set -e | ||
|
||
if [ -z "$1" ]; then | ||
echo "Usage: . drain_pool.sh <pool_id>" | ||
return | ||
fi | ||
|
||
printf "\n------------------------------------------------------------\n" | ||
printf " WARNING!!!!\n" | ||
printf " This will delete all but one long code from a Pinpoint pool!\n" | ||
printf " You do not want to run this or production!\n" | ||
printf "\n------------------------------------------------------------\n" | ||
printf "Are you sure you want to continue?" | ||
echo -n "If so, type 'drain'> " | ||
read -r check | ||
|
||
if [ "$check" != "drain" ]; then | ||
echo "Exiting..." | ||
exit 1 | ||
fi | ||
|
||
if aws pinpoint-sms-voice-v2 describe-pools --pool-ids $1; then | ||
numbers=$(aws pinpoint-sms-voice-v2 list-pool-origination-identities --pool-id $1 | jq -r ".OriginationIdentities[].OriginationIdentity") | ||
read -ra numbersArray <<< $numbers # Split the string into an array | ||
|
||
echo "Found ${#numbersArray[@]} numbers in pool $1. Releasing all but one." | ||
for number in ${numbersArray[@]:1}; do # Skip the first number - have to keep at least one number in the pool | ||
echo "Releasing $number..." | ||
aws pinpoint-sms-voice-v2 disassociate-origination-identity --iso-country-code CA --pool-id $1 --origination-identity $number | ||
aws pinpoint-sms-voice-v2 release-phone-number --phone-number-id $number | ||
done | ||
else | ||
echo "Pool $1 does not exist" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
|
||
# Usage: | ||
# . request_long_codes.sh numberOfLongCodes poolId | ||
|
||
# This script requests a number of long codes from Pinpoint SMS and assigns them to a pool | ||
|
||
set -e | ||
|
||
if [ -z "$1" ]; then | ||
echo "Please provide the number of long codes to request" | ||
exit 1 | ||
fi | ||
if [ $1 -lt 1 ]; then | ||
echo "Number of long codes must be greater than 0" | ||
exit 1 | ||
fi | ||
if [ -z "$2" ]; then | ||
echo "Please provide the pool ID to assign the long codes to" | ||
exit 1 | ||
fi | ||
if ! aws pinpoint-sms-voice-v2 describe-pools --pool-ids $2; then | ||
echo "Pool $2 does not exist" | ||
exit 1 | ||
fi | ||
numberOfLongCodes=$1 | ||
poolId=$2 | ||
|
||
|
||
printf "\n------------------------------------------------------------\n" | ||
printf " WARNING!!!!\n" | ||
printf " This will add new phone numbers to a Pinpoint pool\n" | ||
printf " You might not want to run this in production!\n" | ||
printf "\n------------------------------------------------------------\n" | ||
printf "Are you sure you want to continue?" | ||
echo -n "If so, type 'request'> " | ||
read -r check | ||
|
||
if [ "$check" != "request" ]; then | ||
echo "Exiting..." | ||
exit 1 | ||
fi | ||
|
||
for i in $(seq 1 $numberOfLongCodes); do | ||
number=$(aws pinpoint-sms-voice-v2 request-phone-number \ | ||
--iso-country-code CA --message-type TRANSACTIONAL \ | ||
--number-capabilities SMS \ | ||
--number-type LONG_CODE \ | ||
| jq -r ".PhoneNumberId") | ||
|
||
numberStatus="PENDING" | ||
while [ "$numberStatus" != "\"ACTIVE\"" ]; do | ||
echo "Waiting for number $number to become ACTIVE..." | ||
sleep 1 | ||
numberStatus=$(aws pinpoint-sms-voice-v2 describe-phone-numbers \ | ||
--phone-number-ids $number \ | ||
| jq '.PhoneNumbers[0].Status') | ||
done | ||
|
||
aws pinpoint-sms-voice-v2 associate-origination-identity \ | ||
--pool-id $poolId \ | ||
--origination-identity $number \ | ||
--iso-country-code CA | ||
done |