title: Send an SMS via AWS SNS using boto3 in an AWS Lambda function?
body: <p>I would like to send an SMS message from an AWS Lambda function using the boto3 publish method to notify the user of issues via SMS. My lambda function is written in Python and I am using the boto3 module. My lambda function has full rights to SNS. I have this code,</p>
  
  <pre><code>sns = boto3.client('sns')
  sns.publish(
      PhoneNumber = '+11234567890',
      Message = 'Simple text message'
  )
  </code></pre>
  
  <p>According to the boto3 <a href="http://boto3.readthedocs.io/en/latest/reference/services/sns.html#SNS.Client.publish" rel="noreferrer">documentation</a>, the publish method accepts the following parameters,</p>
  
  <pre><code>response = client.publish(
      TopicArn='string',
      TargetArn='string',
      PhoneNumber='string',
      Message='string',
      Subject='string',
      MessageStructure='string',
      MessageAttributes={
          'string': {
              'DataType': 'string',
              'StringValue': 'string',
              'BinaryValue': b'bytes'
          }
      }
  )
  </code></pre>
  
  <p>It requires a "Message" parameter and one of the following three parameters as described in the docs:</p>
  
  <blockquote>
    <p>TopicArn (string) -- The topic you want to publish to.</p>
    
    <p>If you don't specify a value for the TopicArn parameter, you must
    specify a value for the PhoneNumber or TargetArn parameters.</p>
    
    <p>TargetArn (string) -- Either TopicArn or EndpointArn, but not both.</p>
    
    <p>If you don't specify a value for the TargetArn parameter, you must
    specify a value for the PhoneNumber or TopicArn parameters.</p>
    
    <p>PhoneNumber (string) -- The phone number to which you want to deliver
    an SMS message. Use E.164 format.</p>
    
    <p>If you don't specify a value for the PhoneNumber parameter, you must
    specify a value for the TargetArn or TopicArn parameters.</p>
  </blockquote>
  
  <p>When my code is executed a parameter validation error is returned. It states,  </p>
  
  <blockquote>
    <p>Unknown parameter in input: "PhoneNumber", must be one of: TopicArn,
    TargetArn, >Message, Subject, MessageStructure, MessageAttributes".</p>
  </blockquote>
  
  <p>So the documentation seems to indicate that PhoneNumber is a valid parameter, but when used, an error occurs and the feedback from the error indicates that PhoneNumber is not a possible parameter. I suspect I am missing something obvious and simple, but could use some help.</p>
  
  <p>I know there are other avenues to send SMS messages such as email gateways and other vendor supplied solutions like Twilio, but I would like to pursue the SNS based route and understand where I have gone wrong.</p>