Last active
January 26, 2021 12:12
-
-
Save Kaundur/43a00dc5bcd822807b890eb613478dbd to your computer and use it in GitHub Desktop.
Example script for the generation for AWS SMS notifications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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