Skip to content

Instantly share code, notes, and snippets.

@Kaundur
Last active January 26, 2021 12:12
Show Gist options
  • Save Kaundur/43a00dc5bcd822807b890eb613478dbd to your computer and use it in GitHub Desktop.
Save Kaundur/43a00dc5bcd822807b890eb613478dbd to your computer and use it in GitHub Desktop.
Example script for the generation for AWS SMS notifications
import boto3
# Generated through IAM
aws_access_key_id = ''
aws_secret_access_key = ''
region_name = 'us-west-2'
sns = boto3.client('sns', aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, region_name=region_name)
# Number including region code e.g. +44 for UK numbers
number = ''
# Name that appears at the top of the message
sender_id = 'companyId'
# SMS type can be Transactional (Critical) or Promotional (Non-Critical).
# Transactional have a higher reliability, however can incur additional fees
# sms_type = 'Transactional'
sms_type = 'Promotional'
attributes = {
'AWS.SNS.SMS.SenderID': {
'DataType': 'String',
'StringValue': sender_id
},
'AWS.SNS.SMS.SMSType': {
'DataType': 'String',
'StringValue': sms_type
}
}
message = 'Test SMS Message'
sns.publish(PhoneNumber=number, Message=message, MessageAttributes=attributes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment