# Real-time Pricing

MechCloud displays cost information directly in the plan output before any infrastructure changes are applied. This enables cost-aware infrastructure decisions during development rather than discovering costs after deployment.

### Overview

When generating an execution plan, MechCloud calculates and displays comprehensive cost information for GCP resources that have associated costs.

### Supported Billing Models

| Model                | How it appears in the plan                  | Examples                       |
| -------------------- | ------------------------------------------- | ------------------------------ |
| Usage-based (hourly) | Hourly rate + max monthly total (730 hours) | Compute Engine VM, GKE Cluster |
| Storage (GB-month)   | Rate + total when size is known             | Persistent Disk                |

#### Usage-Based Charges (Price + Cost)

For resources with **predictable usage patterns**, MechCloud shows both price rates and calculated costs:

* Compute Engine instance hours
* Persistent Disk storage (GB-Mo)
* GKE Cluster management fee

Example: A Compute Engine `e2-micro` instance shows `price: $0.00835/Hrs, monthly: $6.10`

### Cost Change Tracking

MechCloud displays cost change percentages for all resource actions, helping you understand the financial impact of infrastructure changes.

#### Create Actions

When creating new resources, the cost change is **+100%** (from $0 to the new cost):

```
vm1 (action: create, price: $0.00835/Hrs, monthly: $6.10, change: +100%)
```

#### Update Actions

When modifying existing resources, the change percentage reflects the actual cost difference.

#### Delete Actions

When deleting resources, the cost change is **-100%** (from current cost to $0):

```
vm1 (action: delete, price: $0.00/Hrs, monthly: $0.00, change: -100%)
```

### Plan Output Examples

#### Compute Engine Instance (Usage-Based Charges)

Compute Engine instances have predictable usage patterns, so MechCloud calculates and displays actual hourly and monthly costs.

**Creating a Compute Engine instance:**

```yaml
defaults:
  zone: us-central1-a

resources:
  - type: compute.v1.instance
    name: vm1
    props:
      machine_type: machineTypes/e2-micro
      disks:
        - boot: true
          auto_delete: true
          initialize_params:
            disk_size_gb: 30
            disk_type: diskTypes/pd-standard
            source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-2404-lts
      network_interfaces:
        - subnetwork: subnetworks/subnet1
          access_configs:
            - type: ONE_TO_ONE_NAT
              name: External NAT
```

**Plan output:**

```
vm1 (action: create)
=> Price (vCPU) - price: $0.02289/Hrs, quantity: 2, monthly: $33.42, change: +100%
=> Price (RAM) - price: $0.00308/GB-Hrs, quantity: 1, monthly: $2.25, change: +100%
=> Price (Boot Disk) - price: $0.04/GB-Mo, quantity: 30, monthly: $1.20, change: +100%
```

The plan shows:

* **vCPU price**: Calculated hourly cost for vCPUs.
* **RAM price**: Calculated hourly cost for Memory (GB).
* **Boot Disk**: Calculated monthly cost for the specified Persistent Disk.
* **Monthly**: Estimated monthly cost (hourly × 730 hours).
* **Change**: `+100%` - new resource.

### Supported Resources

MechCloud provides real-time pricing for the following GCP resource types:

| Offering        | Resource Type                              |
| --------------- | ------------------------------------------ |
| Compute Engine  | Instance (VM)                              |
|                 | Disk (Persistent Disk)                     |
|                 | Address (Static External IP)               |
|                 | Forwarding Rule (Load Balancer)            |
| GKE             | Cluster                                    |
|                 | Node Pool                                  |
| Cloud SQL       | Instance (MySQL / PostgreSQL / SQL Server) |
| Memorystore     | Redis Instance                             |
| Cloud Storage   | Bucket                                     |
| Cloud DNS       | Managed Zone                               |
| Cloud Run       | Service                                    |
| Cloud Functions | Function                                   |
| Pub/Sub         | Topic                                      |
| Cloud Spanner   | Instance                                   |
| Cloud NAT       | Gateway (Router)                           |
| VPN             | Tunnel                                     |

For detailed pricing examples, see [Examples (Resources With Cost)](/cloud-computing/stateless-iac/gcp/examples-resources-with-cost.md).

### Regional Pricing

Costs vary by GCP region. MechCloud automatically applies region-specific pricing.

### Using Pricing Data

#### Track Environment Costs

When generating plans for different Resource Contexts:

```
Development environment (context: app-dev)
Monthly cost: $125.43

Production environment (context: app-prod)
Monthly cost: $892.15
```

### Best Practices

**Include cost justification in code comments** - Document why specific instance types or sizes were chosen.

**Compare costs during code review** - Review cost deltas alongside configuration changes.

**Track cost trends over time** - Save plan outputs to monitor infrastructure cost evolution.

**Use Resource Context for cost isolation** - Separate cost tracking by environment (dev, staging, prod).

**Monitor actual vs estimated costs** - Compare MechCloud estimates against actual cloud bills to refine understanding.

### Integration with Stateless IaC

Real-time pricing works seamlessly with MechCloud's stateless architecture:

**Fresh pricing every plan** - No stale data from state files

**Accurate cost deltas** - Costs compared against actual current state

**Environment isolation** - Resource Context enables per-environment cost tracking

### Next Steps

* [Examples (Resources With Cost)](/cloud-computing/stateless-iac/gcp/examples-resources-with-cost.md)
* [Authoring Desired State](/cloud-computing/stateless-iac/gcp/authoring-desired-state.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mechcloud.io/cloud-computing/stateless-iac/gcp/real-time-pricing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
