Module: Tfrb::Resource::AwsStoragegatewayGateway

Extended by:
Tfrb::Resource
Defined in:
lib/tfrb/resource/aws_storagegateway_gateway.rb

Class Method Summary collapse

Methods included from Tfrb::Resource

aws_options, extended, get_custom_resource, get_state, import!, load_helpers!, resolve_tfvar, set_default

Class Method Details

.load(base, environment_name, resource_type, new_resources) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tfrb/resource/aws_storagegateway_gateway.rb', line 12

def self.load(base, environment_name, resource_type, new_resources)
  new_resources.each do |resource_name, resource|
    client = ::Aws::StorageGateway::Client.new(aws_options(base, resource))
    response = client.list_gateways({
      limit: 100
    })
    if response.gateways && gateway = response.gateways.find { |g| g.gateway_name == resource_name }
      id = gateway.gateway_arn
      import!(base, resource_type, resource_name, id)
    end
  end
end

.preload(base, environment_name, resource_type, new_resources) ⇒ Object



6
7
8
9
10
# File 'lib/tfrb/resource/aws_storagegateway_gateway.rb', line 6

def self.preload(base, environment_name, resource_type, new_resources)
  new_resources.each do |resource_name, resource|
    set_default(resource, 'gateway_name', resource_name.gsub('_', ' '))
  end
end