Class: CloudCostTracker::Coding::Compute::AWS::ServerCodingPolicy

Inherits:
ResourceCodingPolicy show all
Defined in:
lib/cloud_cost_tracker/coding/compute/aws/servers.rb

Overview

Implements the logic for attaching billing codes to EC2 servers

Instance Method Summary collapse

Methods inherited from ResourceCodingPolicy

#initialize, #setup

Constructor Details

This class inherits a constructor from CloudCostTracker::Coding::ResourceCodingPolicy

Instance Method Details

#code(ec2_server) ⇒ Object

Copies all billing codes from this server’s Security Group



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cloud_cost_tracker/coding/compute/aws/servers.rb', line 9

def code(ec2_server)
  ec2_server.groups.each do |group_name|
    group = ec2_server.('security_groups').find do |g|
      g.identity == group_name
    end
    if group
      group.billing_codes.each do |billing_code|
        ec2_server.code(billing_code[0], billing_code[1])
      end
    end
  end
end