# AWS

This page documents the AWS-specific setup and supported resources for Cost Explorer (Gantt).

## Step 1: Add Your AWS Account

Cost Explorer (Gantt) requires your AWS account to be added to MechCloud. Follow the AWS onboarding guide to connect your account:

[Add AWS Account](https://docs.mechcloud.io/cloud-computing/add-an-account/aws)

## Step 2: Configure IAM Permissions

The IAM role created during AWS onboarding must include the following policy:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "CostExplorerPermissions",
      "Effect": "Allow",
      "Action": [
        "cloudtrail:LookupEvents",
        "tag:GetResources",
        "ec2:DescribeInstances",
        "ec2:DescribeVolumes",
        "ec2:DescribeRegions",
        "lightsail:GetInstances",
        "lightsail:GetBundles"
      ],
      "Resource": "*"
    }
  ]
}
```

Without this permission set, timelines may appear incomplete.

## Step 3: Create a Resource Context

A Resource Context defines the logical boundary within which Stateless IaC and related visualizations operate. Follow the Resource Context setup guide:

[Resource Context](https://docs.mechcloud.io/cloud-computing/stateless-iac/resource-context)

## Step 4: Provision Infrastructure Using Stateless IaC

Once the AWS account and Resource Context are configured, infrastructure can be provisioned using Stateless IaC. All resources created using Stateless IaC are logically bound to the selected Resource Context.

Follow the Stateless IaC authoring guide:

[Stateless IaC for AWS](https://docs.mechcloud.io/cloud-computing/stateless-iac/aws)

## Using Cost Explorer

### Selecting Time Range and Month

Cost Explorer supports visualization of AWS cost for the last three months, including the current month. Only a single month can be visualized at a time.

Use the month selector at the top of the screen to choose the month you want to analyze. When you switch months, the timeline reloads to display the selected month's cost data.

For historical months, the timeline displays final billing values. For the current month, the timeline shows both accumulated cost and projected estimates.

<figure><img src="https://3435649067-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQGHt89wn8Cn0pcK36Wir%2Fuploads%2FaAhsEZUSIFS3n5MsG9XH%2Fimage.png?alt=media&#x26;token=e8f72b02-16a1-4906-b6cf-92236b1be6f5" alt=""><figcaption></figcaption></figure>

### Live Only vs All Resources (Current Month Only)

For the current month, Cost Explorer provides two viewing modes:

**Live Only** mode shows only resources that are currently active. Use this to check the cost of your running infrastructure.

**All Resources** mode includes both active and terminated resources. Terminated resources are displayed using striked-out text. Use this to see costs for resources that were terminated during the current month.

For previous months, only a single view is available showing all resources for that period.

<figure><img src="https://3435649067-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQGHt89wn8Cn0pcK36Wir%2Fuploads%2F8XH7F7Jh7VWxc1CqoARN%2FAdobeExpressPhotos_823887e83b064740aa17377d5792c7fa_CopyEdited.png?alt=media&#x26;token=fa18bdc7-0ebc-4540-aa58-c30812e9b93a" alt=""><figcaption></figcaption></figure>

### Understanding Month-to-Date and Estimated Monthly Cost

For the current month, Cost Explorer displays two values:

* **Month-to-date cost**: Actual accumulated spend up to now
* **Estimated monthly cost**: Projected total if current usage continues

For non-current months, both values are identical since billing data is complete.

<figure><img src="https://3435649067-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQGHt89wn8Cn0pcK36Wir%2Fuploads%2Fui9VcsOb8MASTErnesNC%2FAdobeExpressPhotos_be85a159b0a84a05b3daf757fa570f68_CopyEdited.png?alt=media&#x26;token=9278eeaa-a8f1-4972-bbce-d75e68016847" alt=""><figcaption></figcaption></figure>

### Understanding Tooltip Information

Hovering over any bar in the timeline displays a detailed tooltip containing start time, end time, total duration, unit price, and incurred cost.

For active resources, the tooltip also shows the estimated monthly cost.

<figure><img src="https://3435649067-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQGHt89wn8Cn0pcK36Wir%2Fuploads%2Fi5wqt6TVHz1lkdjpEftF%2Fimage.png?alt=media&#x26;token=84188000-16d7-4927-a29a-bbd149d52dd1" alt=""><figcaption></figcaption></figure>

For terminated resources, only the actual incurred cost is shown.

<figure><img src="https://3435649067-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQGHt89wn8Cn0pcK36Wir%2Fuploads%2F9ZnYnmbcI1BYdA6HZAz6%2Fimage.png?alt=media&#x26;token=21a450c9-3276-4eae-801f-f25c6b08f265" alt=""><figcaption></figcaption></figure>

## Demo

{% embed url="<https://www.youtube.com/watch?v=tkhZCTat2Qo>" %}
