Skip to content

Instantly share code, notes, and snippets.

@ddepaoli3
Created June 18, 2019 13:22
Show Gist options
  • Save ddepaoli3/f1021064fae5481b485fadf3cb78bf0a to your computer and use it in GitHub Desktop.
Save ddepaoli3/f1021064fae5481b485fadf3cb78bf0a to your computer and use it in GitHub Desktop.
Send SMS using aws sns
#!/bin/bash
# ./send_sms.sh +3934091929 "ciao ciao" "profile-name"
#Comand to set the default sender Name, i.e. the name you see in sms in the field 'from'
#aws --profile aws-profile sns set-sms-attributes --attributes DefaultSenderID=SenderName
NUMBER=$1
MESSAGE=$2
PROFILE=$3
TOPICARN=`aws sns create-topic --profile $PROFILE --name test-cli | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["TopicArn"]'`
aws sns subscribe --profile $PROFILE --protocol sms --notification-endpoint $NUMBER --topic-arn "$TOPICARN"
aws sns publish --profile $PROFILE --target-arn "$TOPICARN" --message "$MESSAGE"
aws sns delete-topic --profile $PROFILE --topic-arn "$TOPICARN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment