class OpenStax::Aws::Image
Attributes
aws_image[R]
Public Class Methods
find_by_sha(sha:, region:)
click to toggle source
# File lib/openstax/aws/image.rb, line 28 def self.find_by_sha(sha:, region:) Aws::EC2::Client.new(region: region).describe_images({ owners: ['self'], filters: [{name: "tag:sha", values: [sha]}] }).images.map{|aws_image| new(aws_image: aws_image)} end
new(id: nil, region: nil, aws_image: nil)
click to toggle source
# File lib/openstax/aws/image.rb, line 6 def initialize(id: nil, region: nil, aws_image: nil) if aws_image @aws_image = aws_image else if id.nil? || region.nil? raise ArgumentError, "`id` and `region` must be provided" end @aws_image = Aws::EC2::Image.new(id, region: region) end end
Public Instance Methods
get_tag(key:)
click to toggle source
# File lib/openstax/aws/image.rb, line 18 def get_tag(key:) tag = aws_image.tags.find{|tag| tag.key == key} raise "No tag with key #{key} on AMI #{aws_image.image_id}" if tag.nil? tag.value end
sha()
click to toggle source
# File lib/openstax/aws/image.rb, line 24 def sha get_tag(key: "sha") end