Created
April 7, 2015 12:43
-
-
Save Igorshp/de59d5d6d73d0a7bc147 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kitchen | |
module Driver | |
# Amazon EC2 driver for Test Kitchen. | |
# | |
# @author Fletcher Nichol <fnichol@nichol.ca> | |
class Ec2 < Kitchen::Driver::SSHBase | |
include Fog::AWS::CredentialFetcher::ServiceMethods | |
default_config :aws_access_key_id do |driver| | |
ENV['AWS_ACCESS_KEY'] || ENV['AWS_ACCESS_KEY_ID'] || driver.iam_creds[:aws_access_key_id] | |
end | |
default_config :aws_session_token do |driver| | |
ENV['AWS_SESSION_TOKEN'] || ENV['AWS_TOKEN'] || driver.iam_creds[:aws_session_token] | |
end | |
def iam_creds | |
if config[:aws_access_key_id].is_a? Proc | |
raise "and here we have a proc" | |
end | |
@iam_creds ||= begin | |
fetch_credentials(use_iam_profile:true) | |
rescue RuntimeError => e | |
debug("fetch_credentials failed with exception #{e.message}:#{e.backtrace.join("\n")}") | |
{} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment