What I'm trying to accomplish:
- I have a ruby on rails app which uses carrierwave to store data using the fog-aws adapter
- I'm trying to simulate poor communication with AWS S3
What I've done:
I have a sample ruby script which tries to connect to AWS and enumerate objects:
require 'aws-sdk-s3'
params = {region: 'us-west-2', access_key_id: 'key', secret_access_key: 'secret'}
s3 = Aws::S3::Client.new(params)
puts s3.list_objects({bucket: 'bucketname', prefix: '', max_keys: 1})
This works - so the credentials are fine.
I now want to toxify this using toxiproxy (a chaos engineering tool that'll randomly break connections, etc)
- Added an http proxy to the params:
{region: 'us-west-2', access_key_id: 'key', secret_access_key: 'secret', http_proxy: 'http://localhost:7890'} - Created a toxiproxy definition using anything I could think of:
toxiproxy-cli create --listen localhost:7890 -u bucketname.s3.amazonaws.com:443 test-aws
toxiproxy-cli create --listen localhost:7890 -u s3-r-w.us-west-2.amazonaws.com:443 test-aws
I then execute the above mentioned script and all I see is: lib/ruby/2.6.0/net/protocol.rb:225:in 'rbuf_fill': end of file reached (Seahorse::Client::NetworkingError)
I can't figure out the magic parameters required to make everything connect.
So questions:
- Can what I'm trying to accomplish work using toxiproxy?
- If not, what is recommended?
I figured it out. It looks like toxiproxy by itself is not enough to intercept & forward the connection -- I needed to also use tinyproxy.
This is what I did:
Example code:
Example tinyproxy configuration:
Example toxiproxy configuration: