Module: Tfrb::Resource::AwsVolumeAttachment

Extended by:
Tfrb::Resource
Defined in:
lib/tfrb/resource/aws_volume_attachment.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
24
25
26
27
28
29
# File 'lib/tfrb/resource/aws_volume_attachment.rb', line 12

def self.load(base, environment_name, resource_type, new_resources)
  new_resources.each do |resource_name, resource|
    # client = ::Aws::EC2::Client.new(aws_options(base, resource))
    # response = client.describe_volumes({
    #   volume_ids: [
    #     resolve_tfvar(base, resource_type, resource_name, 'volume_id')
    #   ],
    # })
    # if response.volumes && response.volumes.size >= 1
    #   if response.volumes.first.attachments && response.volumes.first.attachments.size >= 1
    #     if response.volumes.first.attachments.find { |a| a.instance_id == resolve_tfvar(base, resource_type, resource_name, 'instance_id') }
    #       id = response.volumes.first.volume_id
    #       import!(base, resource_type, resource_name, id)
    #     end
    #   end
    # end
  end
end

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



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

def self.preload(base, environment_name, resource_type, new_resources)
  new_resources.each do |resource_name, resource|
    set_default(resource, 'volume_id', "${aws_ebs_volume.#{resource_name}.id}")
  end
end