Search code examples
amazon-snsaws-sdk-js

AWS 10DLC cross account


I have a lambda function, SNS topics/subscriptions in Account A, I have a 10DLC campaign/number in Account B

How do I have the lambda function be able to pass a origination id so I can use the 10DLC number? right now I am using SDK v2 and using publish method. I know I will also need to assume a role - would I be right then to assume since I am assuming a pinpoint send role from Account B - my lambda would not be able to use the SNS topic/subscription from account A?

I see these prop here: AWS.MM.SMS.OriginationNumber from https://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html#sms_publish_sdk

But cannot find where to use it on the SDK v3 documentation page


Solution

  • I can't speak to the role part of your question, but as far as using the Origination Number, I can give an example because I just set this up yesterday.

    Here's a Node example for specifying an origin number when sending sms:

    const AWS = require('aws-sdk')
    AWS.config.update({ region: 'us-east-1' })
    const SNS = new AWS.SNS({ apiVersion: '2010-03-31' })
    
    const params = {
      Message: "This is the message you are sending",
      PhoneNumber: "+13334445555", // This is the receiving number
      MessageAttributes: {
        'AWS.SNS.SMS.SMSType': {
          DataType: 'String',
          StringValue: 'Transactional' // Can also be set as Promotional
        },
        'AWS.MM.SMS.OriginationNumber': {
          DataType: 'String',
          StringValue: "+15556667777" // This is the send number
        }
      }
    }
    
    return SNS.publish(params).promise()