Class: Elbas::AWS::LaunchTemplate

Inherits:
Base
  • Object
show all
Defined in:
lib/elbas/aws/launch_template.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#aws_counterpart

Instance Method Summary collapse

Methods inherited from Base

#aws_access_key, #aws_client, aws_client, #aws_credentials, #aws_region, #aws_secret_key

Constructor Details

#initialize(id, name, version) ⇒ LaunchTemplate

Returns a new instance of LaunchTemplate.



6
7
8
9
10
# File 'lib/elbas/aws/launch_template.rb', line 6

def initialize(id, name, version)
  @id = id
  @name = name
  @version = version
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/elbas/aws/launch_template.rb', line 4

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/elbas/aws/launch_template.rb', line 4

def name
  @name
end

#versionObject (readonly)

Returns the value of attribute version.



4
5
6
# File 'lib/elbas/aws/launch_template.rb', line 4

def version
  @version
end

Instance Method Details

#update(ami) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/elbas/aws/launch_template.rb', line 12

def update(ami)
  latest = aws_client.create_launch_template_version({
    launch_template_data: { image_id: ami.id },
    launch_template_id: self.id,
    source_version: self.version
  }).launch_template_version

  self.class.new(
    latest&.launch_template_id,
    latest&.launch_template_name,
    latest&.version_number
  )
end