Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Using IAM role to send SMS via SNS
1. create sns topic
2. Under Amazon SNS > Text messaging (SMS)
Add your phone number and verify it with otp.
by default SMS is in sandbox mode:
Need to create a support ticket to "Exit SMS Sandbox" :weird: which only allows us to send sms on verified number.
2.1 Create a SMS subscirption with thant number, use SMS protocol
3. Create iam role with policy:
"Version": "2012-10-17",
"Statement": [
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "sns:Publish",
"Resource": "arn:aws:sns:us-east-1:xxx:SMS"
4. create iam role and attach the policy above
5. Install awscli and test this policy in action
aws sts get-caller-identity > /tmp/id; aws sns publish --phone-number +97712345 --message "this is cool $(cat /tmp/id)" --region us-east-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment