Skip to content

Commit

Permalink
Merge branch 'main' into COST-4915-cost-model
Browse files Browse the repository at this point in the history
  • Loading branch information
myersCody authored May 9, 2024
2 parents 07d519d + aa0379c commit 1d08f9c
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions koku/reporting/provider/aws/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,74 @@ class Meta:
source_uuid = models.UUIDField(unique=False, null=True)


class AWSCostEntryLineItemSummaryByEC2Compute(models.Model):
"""Represents a monthly aggregation of EC2 compute instance usage hours and costs.
This table stores monthly aggregated data for EC2 compute instances,
detailing usage hours, associated costs and other key attributes.
"""

class PartitionInfo:
partition_type = "RANGE"
partition_cols = ["usage_start"]

class Meta:
"""Meta for AWSCostEntryLineItemSummaryByEC2ComputeResource."""

db_table = "reporting_awscostentrylineitem_summary_by_ec2_compute"

indexes = [
# 'ec2c' for EC2 Compute
models.Index(fields=["usage_start"], name="ec2c_usage_start_idx"),
models.Index(fields=["usage_account_id"], name="ec2c_usage_account_id_idx"),
models.Index(fields=["account_alias"], name="ec2c_account_alias_idx"),
models.Index(fields=["resource_id"], name="ec2c_resource_id_idx"),
models.Index(fields=["instance_name"], name="ec2c_instance_name_idx"),
models.Index(fields=["instance_type"], name="ec2c_instance_type_idx"),
models.Index(fields=["region"], name="ec2c_region_idx"),
models.Index(fields=["operating_system"], name="ec2c_os_idx"),
GinIndex(fields=["tags"], name="ec2c_tags_idx"),
GinIndex(fields=["cost_category"], name="ec2c_cost_category_idx"),
]

uuid = models.UUIDField(primary_key=True)
usage_start = models.DateField(null=False)
usage_end = models.DateField(null=True)
cost_entry_bill = models.ForeignKey("AWSCostEntryBill", on_delete=models.CASCADE, null=True)
account_alias = models.ForeignKey("AWSAccountAlias", on_delete=models.PROTECT, null=True)
organizational_unit = models.ForeignKey("AWSOrganizationalUnit", on_delete=models.SET_NULL, null=True)
usage_account_id = models.CharField(max_length=50, null=False)
resource_id = models.CharField(max_length=256, null=False)
instance_name = models.CharField(max_length=50, null=True)
instance_type = models.CharField(max_length=50, null=True)
operating_system = models.CharField(max_length=50, null=True)
availability_zone = models.CharField(max_length=50, null=True)
region = models.CharField(max_length=50, null=True)
vcpu = models.IntegerField(null=True)
memory = models.CharField(max_length=50, null=True)
unit = models.CharField(max_length=63, null=True)
usage_amount = models.DecimalField(max_digits=24, decimal_places=9, null=True)
normalization_factor = models.FloatField(null=True)
normalized_usage_amount = models.FloatField(null=True)
currency_code = models.CharField(max_length=10)
unblended_rate = models.DecimalField(max_digits=24, decimal_places=9, null=True)
unblended_cost = models.DecimalField(max_digits=24, decimal_places=9, null=True)
markup_cost = models.DecimalField(max_digits=24, decimal_places=9, null=True)
blended_rate = models.DecimalField(max_digits=24, decimal_places=9, null=True)
blended_cost = models.DecimalField(max_digits=24, decimal_places=9, null=True)
markup_cost_blended = models.DecimalField(max_digits=33, decimal_places=15, null=True)
savingsplan_effective_cost = models.DecimalField(max_digits=24, decimal_places=9, null=True)
markup_cost_savingsplan = models.DecimalField(max_digits=33, decimal_places=15, null=True)
calculated_amortized_cost = models.DecimalField(max_digits=33, decimal_places=9, null=True)
markup_cost_amortized = models.DecimalField(max_digits=33, decimal_places=9, null=True)
public_on_demand_cost = models.DecimalField(max_digits=24, decimal_places=9, null=True)
public_on_demand_rate = models.DecimalField(max_digits=24, decimal_places=9, null=True)
tax_type = models.TextField(null=True)
tags = JSONField(null=True)
source_uuid = models.UUIDField(unique=False, null=True)
cost_category = JSONField(null=True)


class AWSAccountAlias(models.Model):
"""The alias table for AWS accounts."""

Expand Down

0 comments on commit 1d08f9c

Please sign in to comment.