Class: Formatron::CloudFormation::Template::VPC::Subnet::Instance::BlockDevices

Inherits:
Object
  • Object
show all
Defined in:
lib/formatron/cloud_formation/template/vpc/subnet/instance/block_devices.rb

Overview

Adds block device mappings to an instance

Instance Method Summary collapse

Constructor Details

#initialize(block_devices:) ⇒ BlockDevices

Returns a new instance of BlockDevices.



11
12
13
# File 'lib/formatron/cloud_formation/template/vpc/subnet/instance/block_devices.rb', line 11

def initialize(block_devices:)
  @block_devices = block_devices
end

Instance Method Details

#merge(properties:) ⇒ Object

rubocop:disable Metrics/MethodLength



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/formatron/cloud_formation/template/vpc/subnet/instance/block_devices.rb', line 16

def merge(properties:)
  return if @block_devices.length == 0
  block_device_mappings = @block_devices.map do |block_device|
    Resources::EC2.block_device_mapping(
      device: block_device.device,
      size: block_device.size,
      type: block_device.type,
      iops: block_device.iops
    )
  end
  properties[Resources::EC2::BLOCK_DEVICE_MAPPINGS] =
    block_device_mappings
end