Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename pinpoint pool #1339

Merged
merged 2 commits into from
May 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions aws/pinpoint_to_sqs_sms_callbacks/create_pinpoint_pools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Usage:
# . create_pinpoint_pools.sh iam_role_arn log_group_deliveries_arn log_group_failures_arn

# This script creates a shortcode and longcode pool in Pinpoint SMS Voice as well as a configuration set with two event destinations
# This script creates a shortcode and default pool in Pinpoint SMS Voice as well as a configuration set with two event destinations
# The event destinations are used to log all events and failures to CloudWatch Logs
# The script takes three arguments:
# 1. The IAM role ARN that will be used to write to the CloudWatch Logs
Expand All @@ -28,19 +28,19 @@ iamRoleArn=$1
logGroupArnDeliveries=$2
logGroupArnFailures=$3

# Create pools for the shortcode and longcodes
# Create pools for the shortcode and default numbers

poolArns=$(aws pinpoint-sms-voice-v2 describe-pools --output json | jq -r '.Pools.[].PoolArn')
shortcodePoolExists=false
longcodePoolExists=false
defaultPoolExists=false
for poolArn in $poolArns; do
isShort=$(aws pinpoint-sms-voice-v2 list-tags-for-resource --resource-arn $poolArn | jq -r '.Tags[].Value' | grep "shortcode-pool" | wc -l)
isLong=$(aws pinpoint-sms-voice-v2 list-tags-for-resource --resource-arn $poolArn | jq -r '.Tags[].Value' | grep 'longcode-pool' | wc -l)
isDefault=$(aws pinpoint-sms-voice-v2 list-tags-for-resource --resource-arn $poolArn | jq -r '.Tags[].Value' | grep 'default-pool' | wc -l)
if [ $isShort == 1 ]; then
shortcodePoolExists=true
fi
if [ $isLong == 1 ]; then
longcodePoolExists=true
if [ $isDefault == 1 ]; then
defaultPoolExists=true
fi
done

Expand All @@ -51,12 +51,12 @@ else
number1=$(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")
aws pinpoint-sms-voice-v2 create-pool --origination-identity $number1 --iso-country-code CA --message-type TRANSACTIONAL --tags Key=Name,Value=shortcode-pool
fi
if [ $longcodePoolExists == true ]; then
echo "Longcode pool already exists"
if [ $defaultPoolExists == true ]; then
echo "Default pool already exists"
else
echo "Creating longcode pool"
echo "Creating default pool"
number2=$(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")
aws pinpoint-sms-voice-v2 create-pool --origination-identity $number2 --iso-country-code CA --message-type TRANSACTIONAL --tags Key=Name,Value=longcode-pool
aws pinpoint-sms-voice-v2 create-pool --origination-identity $number2 --iso-country-code CA --message-type TRANSACTIONAL --tags Key=Name,Value=default-pool
fi

# # Create a configuration set and assign destinations
Expand Down
Loading