Repository is archived
No commit activity in last 3 years
No release in over 3 years
Checks for AWS IP ranges, including adding to Rack trusted proxy list.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.14
>= 0
~> 10.0
~> 3.0
 Project Readme

AWS IP address utilities

Useful for checking if an IP address belongs to an AWS subnet. The gem automatically updates and publishes itself every day, publishing only takes place if the AWS IP ranges change.

The prefixes get retrieved from https://ip-ranges.amazonaws.com/ip-ranges.json

Build Status

Installation

Add this line to your application's Gemfile:

gem 'aws_ip_utilities'

And then execute:

$ bundle

Or install it yourself as:

$ gem install aws_ip_utilities

Usage

You can check if an IP address belongs to AWS by doing a check:

AwsIpUtilities.aws_ip?(your_ip_addr) #=> true or false

Find out what region the IP is in:

AwsIpUtilities.region_for(your_ip_addr) #=> "eu-west-1"

and determine what service it provides:

AwsIpUtilities.service_for(your_ip_addr) #=> "CLOUDFRONT"

To make Rack::Request trust all AWS machines as a proxies for determining the client IP (when it gets injected into X-Forwarded-For) call the following method:

AwsIpUtilities.make_aws_rack_trusted_proxy!

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/WeTransfer/aws_ip_utilities.