Gotcha: AWS SDK Proxy Setup with Test Kitchen

Featured image for sharing metadata for article

I hit an interesting issue today while testing a cookbook, using Test Kitchen against an EC2, that interacts with the AWS SDK.

The cookbook reached out to the AWS APIs using the AWS SDK Ruby gem, and I was constructing the client as such:

client =
  region: region_name,

When reaching out to the EC2 APIs, I was receiving an error similar to:

Seahorse::Client::NetworkingError (Failed to open TCP connection to localhost:55555)

What's interesting here is that I run a proxy on my development machine, on port 55555. This immediately flagged up as something odd, because this is running on an EC2, so it shouldn't be trying to use my local proxy settings, but instead the proxy on the EC2, which has a different configuration.

You'll notice that when configuring the AWS SDK, I'm not specifying any details about the proxy, so how is it picking them up? When Test Kitchen executes, it will pass certain environment variables to the running instance, one of those being the proxy variables.

So that explains why the local proxy is trying to be used, but how do I specify them for the AWS environment it's in? We can use the http_proxy parameter:

# via Ohai/self-specified attributes
client =
  region: region_name,
  http_proxy: node['proxy']

This then resolved the issue, as the proxy was being used correctly, and the AWS didn't need to fall back to using the environment variable.

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #chef #test-kitchen #proxy.

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.