Class: Serverspec::Type::AWS::EC2::Image
- Inherits:
-
Base
- Object
- Base
- Serverspec::Type::AWS::EC2::Image
- Defined in:
- lib/resources/ec2/image.rb
Overview
The Instance class exposes the EC2::Image resources
Instance Attribute Summary collapse
-
#image_id ⇒ Object
readonly
The ID of the AMI.
-
#image_name ⇒ Object
readonly
The Name tag of the Instance (if available).
-
#instance_id ⇒ Object
readonly
The ID of the Instance.
Instance Method Summary collapse
-
#initialize(image_id_name, instance = nil) ⇒ Image
constructor
AWS SDK for Ruby v2 Aws::EC2::Client wrapper for initializing an Instance resource.
- #root_volume ⇒ Object
-
#to_s ⇒ String
Returns the string representation of EC2::Instance.
Constructor Details
#initialize(image_id_name, instance = nil) ⇒ Image
AWS SDK for Ruby v2 Aws::EC2::Client wrapper for initializing an Instance resource
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/resources/ec2/image.rb', line 22 def initialize(image_id_name, instance = nil) check_init_arg 'image_id_name', 'EC2::image', image_id_name @aws = instance.nil? ? Aws::EC2::Client.new : instance if image_id_name.match(/^ami-[A-Fa-f0-9]{8,17}$/).nil? @image_name = image_id_name get_image_by_name image_id_name else @image_id = image_id_name get_image_by_id image_id_name end end |
Instance Attribute Details
#image_id ⇒ Object (readonly)
The ID of the AMI
13 14 15 |
# File 'lib/resources/ec2/image.rb', line 13 def image_id @image_id end |
#image_name ⇒ Object (readonly)
The Name tag of the Instance (if available)
11 12 13 |
# File 'lib/resources/ec2/image.rb', line 11 def image_name @image_name end |
#instance_id ⇒ Object (readonly)
The ID of the Instance
9 10 11 |
# File 'lib/resources/ec2/image.rb', line 9 def instance_id @instance_id end |
Instance Method Details
#root_volume ⇒ Object
41 42 43 44 45 46 |
# File 'lib/resources/ec2/image.rb', line 41 def root_volume root_vol = @image.block_device_mappings.first do |vol| vol.device_name == @image.root_device_name end Volume.new(root_vol, @image.root_device_type) end |
#to_s ⇒ String
Returns the string representation of EC2::Instance
36 37 38 39 |
# File 'lib/resources/ec2/image.rb', line 36 def to_s return "EC2 Image ID: #{@image_id}" if @image_name.nil? "EC2 Image ID: #{@image_id}; Name: #{@image_name}" end |