Method: AwsResourceMixin#initialize

Defined in:
lib/resource_support/aws/aws_resource_mixin.rb

#initialize(resource_params = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/resource_support/aws/aws_resource_mixin.rb', line 2

def initialize(resource_params = {})
  Inspec.deprecate(:aws_resources_in_resource_pack,
                   "Resource '#{@__resource_name__ ||= self.class.to_s}'")
  validate_params(resource_params).each do |param, value|
    instance_variable_set(:"@#{param}", value)
  end
  catch_aws_errors do
    fetch_from_api
  end
rescue ArgumentError => e
  # continue with ArgumentError if testing
  raise unless respond_to?(:inspec) && inspec

  raise Inspec::Exceptions::ResourceFailed, e.message
end