class Kitchen::Driver::Aws::Client
A class for creating and managing the EC2 client connection
@author Tyler Ball <tball@chef.io>
Public Class Methods
Source
# File lib/kitchen/driver/aws/client.rb, line 31 def initialize( region, profile_name = "default", http_proxy = nil, retry_limit = nil, ssl_verify_peer = true ) ::Aws.config.update( region:, profile: profile_name, http_proxy:, ssl_verify_peer: ) ::Aws.config.update(retry_limit:) unless retry_limit.nil? end
Public Instance Methods
Source
# File lib/kitchen/driver/aws/client.rb, line 81 def client @client ||= ::Aws::EC2::Client.new end
Source
# File lib/kitchen/driver/aws/client.rb, line 51 def create_instance(options) resource.create_instances(options).first end
create a new AWS EC2 instance @param options [Hash] has of instance options @see docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Resource.html#create_instances-instance_method @return [Aws::EC2::Instance]
Source
# File lib/kitchen/driver/aws/client.rb, line 58 def get_instance(id) resource.instance(id) end
get an instance object given an id @param id [String] aws instance id @return [Aws::EC2::Instance]
Source
# File lib/kitchen/driver/aws/client.rb, line 65 def get_instance_from_spot_request(request_id) resource.instances( filters: [{ name: "spot-instance-request-id", values: [request_id], }] ).to_a[0] end
get an instance object given a spot request ID @param request_id [String] aws spot instance id @return [Aws::EC2::Instance]
Source
# File lib/kitchen/driver/aws/client.rb, line 77 def instance_exists?(id) resource.instance(id).exists? end
check if instance exists, given an id @param id [String] aws instance id @return boolean
Source
# File lib/kitchen/driver/aws/client.rb, line 85 def resource @resource ||= ::Aws::EC2::Resource.new end