Skip to content

Commit

Permalink
Merge pull request #580 from sverch/master
Browse files Browse the repository at this point in the history
Add support for a custom aws endpoint
  • Loading branch information
k1LoW authored Apr 8, 2023
2 parents 141a6b0 + a27a724 commit d8e5ce2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions lib/awspec/helper/finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d8e5ce2

Please sign in to comment.