Skip to content

How can i use SNS publish to send a SMS message using a phone number in another account.

0

I am looking for documentation on how to configure SNS sms publish to use a phone number from another account.

Using CLI

aws pinpoint-sms-voice-v2 describe-phone-numbers --owner SHARED

I can see my shared phone number is visible, I can even send a message using it with aws pinpoint-sms-voice-v2 send-text-message ...

However, I cannot figure out how to default SNS to use that number or use the SNS CLI to leverage that number. I am looking to use the shared phone number for cognito, which flows through SNS. I have tried:

aws sns publish --phone-number +{{phone_number}} --message "HI JARED"

This fails with message: No origination identity available to send to destination number

2 Answers
1

Hi, Please follow the detailed steps below::

1. Source Account Setup (Account owning the phone number)

# Verify phone number sharing status
aws pinpoint-sms-voice-v2 describe-phone-numbers --phone-number-id your-phone-id

# Enable sharing for the phone number
aws pinpoint-sms-voice-v2 update-phone-number \
    --phone-number-id your-phone-id \
    --sharing-status SHARED

# Add resource policy
aws pinpoint-sms-voice-v2 put-resource-policy \
    --resource-arn "arn:aws:sms-voice:region:source-account:phone-number/phone-id" \
    --policy '{
        "Version": "2012-10-17",
        "Statement": [{
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::destination-account:root"
            },
            "Action": [
                "sms-voice:SendTextMessage",
                "sms-voice:DescribePhoneNumbers"
            ],
            "Resource": "arn:aws:sms-voice:region:source-account:phone-number/phone-id"
        }]
    }'

2. Destination Account Setup

# Verify shared phone number is visible
aws pinpoint-sms-voice-v2 describe-phone-numbers --owner SHARED

# Create origination pool
aws pinpoint-sms-voice-v2 create-pool \
    --origination-identity "arn:aws:sms-voice:region:source-account:phone-number/phone-id" \
    --iso-country-code US \
    --message-type TRANSACTIONAL

# Configure SNS to use the pool
aws sns set-sms-attributes \
    --attributes "DefaultSMSType=Transactional,DefaultSenderID=your-pool-id"

# Test message sending
aws sns publish \
    --phone-number "+1234567890" \
    --message "Test message"

3. For Cognito Integration

# Update Cognito SMS configuration
aws cognito-idp update-user-pool \
    --user-pool-id your-pool-id \
    --sms-configuration '{
        "SnsCallerArn": "arn:aws:iam::account-id:role/your-sns-role",
        "ExternalId": "your-external-id"
    }'

For more details:

AWS
answered a year ago
EXPERT
reviewed a year ago
0

Hi,

First, check if the phone number can be shared. Then, enable sharing for that number. Finally, set up a resource policy to allow the destination account to use the phone number for sending text messages and viewing its details.

Setting up the Destination Account

Start by confirming that the shared phone number is visible. Next, create a pool for originating messages using the shared number. Then, configure SNS to use this pool. Lastly, test sending a message.

Integrating with Cognito

Update the Cognito user pool's SMS configuration with the appropriate SNS role and external ID.

AWS
answered a year ago
EXPERT
reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.