any_sms-backend-aws

AnySMS backend for using amazon web services sms delivery


Keywords
anysms, aws, aws-sns, sms, sms-api, sms-backend, sms-service
License
MIT
Install
gem install any_sms-backend-aws -v 0.1.0

Documentation

AnySMS::Backend::AWS

Build Status

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:

  1. Go to AWS registration page

  2. After you registered and logged in, go to IAM users

  3. Click "Create new users", enter username of your wish (in my case testuser) and then click "Create".

  4. You should see similar picture:

    security credentials

    save access key id and secret acces key somwhere.

  5. Now close popup and click on the user.

  6. Click Permissions tab. It will look like this

    permissions tab

  7. Click on Attach Policy, then filter by SNS.

  8. 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 AWS_ACCESS_KEY, AWS_SECRET_ACCESS_KEY and AWS_REGION environment variables.

!!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

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Fedcomp/any_sms-backend-aws.

License

The gem is available as open source under the terms of the MIT License.