Class: AWSCDK::EC2::AmazonLinuxImage

Inherits:
GenericSSMParameterImage
  • Object
show all
Defined in:
ec2/amazon_linux_image.rb

Overview

Selects the latest version of Amazon Linux.

This Machine Image automatically updates to the latest version on every deployment. Be aware this will cause your instances to be replaced when a new version of the image becomes available. Do not store stateful information on the instance if you are using this image.

The AMI ID is selected using the values published to the SSM parameter store.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(props = nil) ⇒ AmazonLinuxImage

Returns a new instance of AmazonLinuxImage.

Parameters:



16
17
18
19
20
# File 'ec2/amazon_linux_image.rb', line 16

def initialize(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::EC2::AmazonLinuxImageProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkFtYXpvbkxpbnV4SW1hZ2VQcm9wcyJ9")), "props") unless props.nil?
  Jsii::Object.instance_method(:initialize).bind(self).call(props)
end

Class Method Details

.jsii_overridable_methodsObject



22
23
24
25
26
27
# File 'ec2/amazon_linux_image.rb', line 22

def self.jsii_overridable_methods
  {
    :parameter_name => { kind: :property, name: "parameterName", is_optional: false },
    :get_image => { kind: :method, name: "getImage", is_optional: false },
  }
end

.ssm_parameter_name(props = nil) ⇒ String

Return the SSM parameter name that will contain the Amazon Linux image with the given attributes.

Parameters:

Returns:

  • (String)


33
34
35
36
37
# File 'ec2/amazon_linux_image.rb', line 33

def self.ssm_parameter_name(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::EC2::AmazonLinuxImageProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkFtYXpvbkxpbnV4SW1hZ2VQcm9wcyJ9")), "props") unless props.nil?
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.AmazonLinuxImage", "ssmParameterName", [props])
end

Instance Method Details

#get_image(scope) ⇒ AWSCDK::EC2::MachineImageConfig

Return the image to use in the given context.

Parameters:

  • scope (Constructs::Construct)

Returns:



50
51
52
53
# File 'ec2/amazon_linux_image.rb', line 50

def get_image(scope)
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  jsii_call_method("getImage", [scope])
end

#parameter_nameString

Name of the SSM parameter we're looking up.

Returns:

  • (String)


42
43
44
# File 'ec2/amazon_linux_image.rb', line 42

def parameter_name()
  jsii_get_property("parameterName")
end