Sha256: 2f1d70162351540cb636a4e95ebd1f206c8ae1d32b460f18242787f1a3778138
Contents?: true
Size: 730 Bytes
Versions: 2
Compression:
Stored size: 730 Bytes
Contents
require 'aws-sdk' require_relative 'tag_util' module Tagenv module Ec2 class Tag def initialize @logger = Logger.new(STDOUT) region = ENV['AWS_REGION'] || Metadata.get_document['region'] @ec2 = Aws::EC2::Client.new(region: region) end def get_tag_hash(instance_id) instance_id = instance_id || Metadata.get_instance_id instances_tag_with_id(instance_id) end private def instances_tag_with_id(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(tags) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tagenv-0.1.3 | lib/tagenv/ec2/tag.rb |
tagenv-0.1.2 | lib/tagenv/ec2/tag.rb |