diff --git a/README.md b/README.md index dbbed0bf..daf6b32d 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,26 @@ Awspec.configure do |config| end ``` +### Advanced Tips: Setting A Custom Endpoint + +Set the `endpoint` environment variable to tell awspec to use a different +endpoint to connect to aws. Common use cases are connecting to aws through a +proxy, using a different service with an aws compatible interface, or +connecting to a local mock aws environment. + +For example, first create a resource on a local aws service using the aws cli: + +``` +AWS_SECRET_ACCESS_KEY=dummy AWS_ACCESS_KEY_ID=dummy \ + aws --endpoint-url http://localhost:5000 s3 mb s3://my-bucket +``` + +Then you can tell awspec to run the test suite using the same custom endpoint: + +``` +endpoint=http://localhost:5000 bundle exec rake spec +``` + ## Support AWS Resources [Resource Types information here](doc/resource_types.md) diff --git a/lib/awspec/helper/finder.rb b/lib/awspec/helper/finder.rb index 849b883f..8106307e 100644 --- a/lib/awspec/helper/finder.rb +++ b/lib/awspec/helper/finder.rb @@ -173,6 +173,13 @@ module Finder http_wire_trace: ENV['http_wire_trace'] || false } + # We have to set this conditionally after defining `CLIENT_OPTIONS`, + # because setting the `endpoint` argument to `nil` results in an error from + # the aws sdk. + if ENV.key?('endpoint') + CLIENT_OPTIONS[:endpoint] = ENV['endpoint'] + end + check_configuration = ENV['DISABLE_AWS_CLIENT_CHECK'] != 'true' if ENV.key?('DISABLE_AWS_CLIENT_CHECK') # define_method below will "hide" any exception that comes from bad