Sha256: bbd93cfc8376d529ee1d75c0c3036cffe3ce68e348b1c5f2d5b071fed51640bf
Contents?: true
Size: 793 Bytes
Versions: 3
Compression:
Stored size: 793 Bytes
Contents
require 'aws-sdk' require_relative 'tag_util' module Tagenv module Ec2 class Tag def initialize(prefix: '', instance_id: nil) @logger = Logger.new(STDOUT) region = ENV['AWS_REGION'] || Metadata.get_document['region'] @ec2 = Aws::EC2::Client.new(region: region) @prefix = prefix @instance_id = instance_id end def get_tag_hash instances_tag_with_id end private def instances_tag_with_id @instance_id = @instance_id || Metadata.get_instance_id tags = @ec2.describe_instances( instance_ids: [@instance_id] ).data.to_h[:reservations].map { |instance| instance[:instances].first }.first[:tags] TagUtil.convert_tag_hash(@prefix, tags) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tagenv-0.1.7 | lib/tagenv/ec2/tag.rb |
tagenv-0.1.6 | lib/tagenv/ec2/tag.rb |
tagenv-0.1.5 | lib/tagenv/ec2/tag.rb |