AnySMS backend to send sms using AWS SNS service.
Before installation - obtaining token
Before you can use this gem, you should get tokens from amazon web services (AWS). Here are steps to achieve that:
Go to AWS registration page
After you registered and logged in, go to IAM users
Click "Create new users", enter username of your wish (in my case
testuser) and then click "Create".
You should see similar picture:
save access key id and secret acces key somwhere.
Now close popup and click on the user.
Click Permissions tab. It will look like this
Click on Attach Policy, then filter by SNS.
Check AmazonSNSFullAccess, click Attach Policy (at the bottom)
This is simple example on how to get them and make things work quick. In reality AWS support various access options, you may read them here and configure it more strict or closer to your needs.
Installation & usage
Add this line to your application's Gemfile:
gem "any_sms-backend-aws", "~> 1.0"
Then somewhere in your initialization code:
require "any_sms-backend-aws" AnySMS.configure do |c| c.register_backend(:my_aws_backend, AnySMS::Backend::AWS, access_key: ENV["AWS_ACCESS_KEY"], secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"], region: ENV["AWS_REGION"] # Optional, default will be "us-east-1" ) c.default_backend = :my_aws_backend end
This is an simple example configuration.
Before running application you should specify
!!Make sure you never commit credentials (secrets) to your repository!!
Now, whenever you need to send SMS, just do:
# Will immediately send sms using AWS sns AnySMS.send_sms("+10000000000", "My sms text")
For more advanced usage please go to AnySMS documentation
Bug reports and pull requests are welcome on GitHub at https://github.com/Fedcomp/any_sms-backend-aws.
The gem is available as open source under the terms of the MIT License.