Class: CloudCostTracker::Coding::Compute::AWS::AccountCodingPolicy

Inherits:
AccountCodingPolicy show all
Defined in:
lib/cloud_cost_tracker/coding/compute/aws/account_coding_policy.rb

Overview

Implements the logic for attaching billing codes to all resources in a single AWS EC2 account, and defines the default order in which EC2 resources get coded.

Instance Method Summary collapse

Methods inherited from AccountCodingPolicy

#code, #initialize, #setup

Constructor Details

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

Instance Method Details

#attach_account_codes(resource) ⇒ Object

Translates all AWS Tags into Billing Codes



26
27
28
29
30
31
32
# File 'lib/cloud_cost_tracker/coding/compute/aws/account_coding_policy.rb', line 26

def (resource)
  if resource.respond_to?(:tags) and resource.tags
    resource.tags.each do |key, value|
      resource.code(key, value)
    end
  end
end

#priority_classesArray <Class>

Defines the order in which EC2 resources are coded.

Returns:

  • (Array <Class>)

    the class names, in preferred coding order



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cloud_cost_tracker/coding/compute/aws/account_coding_policy.rb', line 13

def priority_classes
  [
    Fog::Compute::AWS::Tag,
    Fog::Compute::AWS::SecurityGroup,
    Fog::Compute::AWS::KeyPair,
    Fog::Compute::AWS::Server,    # pulls codes from security group
    Fog::Compute::AWS::Volume,    # pulls codes from server
    Fog::Compute::AWS::Snapshot,  # pulls codes from volume
    Fog::Compute::AWS::Address,
  ]
end