Sha256: d24c38eed672867ffe19e8880ce2d1b05d050f2fae0e5a8c79dabe593abe951e
Contents?: true
Size: 903 Bytes
Versions: 4
Compression:
Stored size: 903 Bytes
Contents
class AwsInventory::Ec2 < AwsInventory::Base def header ["Name", "Instance Id", "Instance Type", "Platform", "Security Groups"] end def data instances.map do |i| name = name_from_tag(i) group_names = security_group_names(i) [ name, i.instance_id, i.instance_type, platform(i), # windows or linux group_names, ] end end def name_from_tag(instance) tags = instance.tags name_tag = tags.find { |t| t.key == "Name" } name_tag ? name_tag.value : "(unnamed)" end def security_group_names(instance) instance.security_groups.map {|sg| sg.group_name}.join(', ') end def cost(instance) cost_type = COST_MAP[instance.instance_type] if cost_type cost = cost_type[platform(instance)] cost.round(2) end end def platform(instance) instance.platform || "linux" end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
aws-inventory-0.4.5 | lib/aws_inventory/ec2.rb |
aws-inventory-0.4.3 | lib/aws_inventory/ec2.rb |
aws-inventory-0.4.2 | lib/aws_inventory/ec2.rb |
aws-inventory-0.4.0 | lib/aws_inventory/ec2.rb |