Class: AWSCDK::Autoscaling::CfnLaunchConfiguration::BlockDeviceMappingProperty

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
autoscaling/cfn_launch_configuration.rb

Overview

BlockDeviceMapping specifies a block device mapping for the BlockDeviceMappings property of the AWS::AutoScaling::LaunchConfiguration resource.

Each instance that is launched has an associated root device volume, either an Amazon EBS volume or an instance store volume. You can use block device mappings to specify additional EBS volumes or instance store volumes to attach to an instance when it is launched.

For more information, see Example block device mapping in the Amazon EC2 User Guide for Linux Instances .

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device_name:, ebs: nil, no_device: nil, virtual_name: nil) ⇒ BlockDeviceMappingProperty

Returns a new instance of BlockDeviceMappingProperty.

Parameters:

  • device_name (String)

    The device name assigned to the volume (for example, /dev/sdh or xvdh ).

  • ebs (AWSCDK::IResolvable, AWSCDK::Autoscaling::CfnLaunchConfiguration::BlockDeviceProperty, nil) (defaults to: nil)

    Information to attach an EBS volume to an instance at launch.

  • no_device (Boolean, AWSCDK::IResolvable, nil) (defaults to: nil)

    Setting this value to true prevents a volume that is included in the block device mapping of the AMI from being mapped to the specified device name at launch.

  • virtual_name (String, nil) (defaults to: nil)

    The name of the instance store volume (virtual device) to attach to an instance at launch.



740
741
742
743
744
745
746
747
748
749
# File 'autoscaling/cfn_launch_configuration.rb', line 740

def initialize(device_name:, ebs: nil, no_device: nil, virtual_name: nil)
  @device_name = device_name
  Jsii::Type.check_type(@device_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "deviceName")
  @ebs = ebs.is_a?(Hash) ? ::AWSCDK::Autoscaling::CfnLaunchConfiguration::BlockDeviceProperty.new(**ebs.transform_keys(&:to_sym)) : ebs
  Jsii::Type.check_type(@ebs, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19hdXRvc2NhbGluZy5DZm5MYXVuY2hDb25maWd1cmF0aW9uLkJsb2NrRGV2aWNlUHJvcGVydHkifV19fQ==")), "ebs") unless @ebs.nil?
  @no_device = no_device
  Jsii::Type.check_type(@no_device, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3sicHJpbWl0aXZlIjoiYm9vbGVhbiJ9LHsiZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifV19fQ==")), "noDevice") unless @no_device.nil?
  @virtual_name = virtual_name
  Jsii::Type.check_type(@virtual_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "virtualName") unless @virtual_name.nil?
end

Instance Attribute Details

#device_nameString (readonly)

The device name assigned to the volume (for example, /dev/sdh or xvdh ).

For more information, see Device naming on Linux instances in the Amazon EC2 User Guide .

To define a block device mapping, set the device name and exactly one of the following properties: Ebs , NoDevice , or VirtualName .



759
760
761
# File 'autoscaling/cfn_launch_configuration.rb', line 759

def device_name
  @device_name
end

#ebsAWSCDK::IResolvable, ... (readonly)

Information to attach an EBS volume to an instance at launch.



764
765
766
# File 'autoscaling/cfn_launch_configuration.rb', line 764

def ebs
  @ebs
end

#no_deviceBoolean, ... (readonly)

Setting this value to true prevents a volume that is included in the block device mapping of the AMI from being mapped to the specified device name at launch.

If NoDevice is true for the root device, instances might fail the EC2 health check. In that case, Amazon EC2 Auto Scaling launches replacement instances.



771
772
773
# File 'autoscaling/cfn_launch_configuration.rb', line 771

def no_device
  @no_device
end

#virtual_nameString? (readonly)

The name of the instance store volume (virtual device) to attach to an instance at launch.

The name must be in the form ephemeral X where X is a number starting from zero (0), for example, ephemeral0 .



778
779
780
# File 'autoscaling/cfn_launch_configuration.rb', line 778

def virtual_name
  @virtual_name
end

Class Method Details

.jsii_propertiesObject



780
781
782
783
784
785
786
787
# File 'autoscaling/cfn_launch_configuration.rb', line 780

def self.jsii_properties
  {
    :device_name => "deviceName",
    :ebs => "ebs",
    :no_device => "noDevice",
    :virtual_name => "virtualName",
  }
end

Instance Method Details

#to_jsiiObject



789
790
791
792
793
794
795
796
797
798
# File 'autoscaling/cfn_launch_configuration.rb', line 789

def to_jsii
  result = {}
  result.merge!({
    "deviceName" => @device_name,
    "ebs" => @ebs,
    "noDevice" => @no_device,
    "virtualName" => @virtual_name,
  })
  result.compact
end