Class: Kitchen::Driver::Aws::StandardPlatform::Amazon2023

Inherits:
StandardPlatform
  • Object
show all
Defined in:
lib/kitchen/driver/aws/standard_platform/amazon2023.rb

Overview

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_image(driver, image) ⇒ Amazon2023?

Detect this platform from an EC2 image.

Matching is done on the image name, which is the only reliable signal EC2 exposes about what an AMI actually contains.

Parameters:

  • driver (Kitchen::Driver::Ec2)

    the driver requesting detection

  • image (Aws::EC2::Image)

    the image to inspect

Returns:

  • (Amazon2023, nil)

    a platform when the image is Amazon Linux 2023, otherwise nil



60
61
62
63
64
65
66
67
68
69
# File 'lib/kitchen/driver/aws/standard_platform/amazon2023.rb', line 60

def self.from_image(driver, image)
  return unless /al2023-ami/i.match?(image.name)

  # `(\.\d+)?`, not `(\.\d+[\.\d])?`: the character class matched the
  # separator that follows the minor version, capturing it into the
  # version string ("2018.03.") and failing outright when the minor
  # version was followed by anything but a dot or digit.
  image.name =~ /\b(\d+(\.\d+)?)/i
  new(driver, "amazon2023", (Regexp.last_match || [])[1], image.architecture)
end

Instance Method Details

#image_searchHash{String => String, Array<String>}

EC2 image filters that select Amazon Linux 2023 AMIs published by AWS.

A filter is added for Kitchen::Driver::Aws::StandardPlatform#architecture only when one was requested, so that an unspecified architecture matches any of them.

Returns:

  • (Hash{String => String, Array<String>})

    filter name to the value or values it must match

See Also:



43
44
45
46
47
48
49
50
# File 'lib/kitchen/driver/aws/standard_platform/amazon2023.rb', line 43

def image_search
  search = {
    "owner-id" => "137112412989",
    "name" => version ? "al2023-ami-2023.#{version}*" : "al2023-ami-2023.*",
  }
  search["architecture"] = architecture if architecture
  search
end

#usernameString

The account EC2 creates on this platform's official AMIs.

Used as the SSH username when the transport does not specify one.

Returns:

  • (String)

    the default SSH username



31
32
33
# File 'lib/kitchen/driver/aws/standard_platform/amazon2023.rb', line 31

def username
  "ec2-user"
end