Repository is archived
No commit activity in last 3 years
No release in over 3 years
ActiveSMS backend for using amazon web services sms delivery
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.12
~> 2.14
~> 10.0
~> 3.0
~> 2.1

Runtime

 Project Readme

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"
    default_sender_id: ENV["AWS_SNS_DEFAULT_SENDER_ID"] # Optional
  )

  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 environment variables. Optionally you can specify AWS_REGION and AWS_SNS_DEFAULT_SENDER_ID (sms sender as text instead of phone).

Keep in mind that AWS_SNS_DEFAULT_SENDER_ID is changing ACCOUNT SETTINGS, and is NOT per request. In case you know how to set it per request - please open issue.

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