Skip to content

Commit

Permalink
Merge pull request #4 from hic-infra/dev
Browse files Browse the repository at this point in the history
Allow querying by any two dimensions/tags, replace `--message-mode` with `--output`
  • Loading branch information
manics committed Aug 7, 2023
2 parents d47f5e4 + e37518c commit 431b7bb
Show file tree
Hide file tree
Showing 16 changed files with 406 additions and 428 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ repos:
- id: bandit
entry: bandit
exclude: ^tests/
exclude: "^tests/dummy-.*/*.md$"
exclude: "^tests/dummy-.*/.*.md$"
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,41 @@ Costs for yesterday, split by service
aws-costs
```

Costs for December 2022, split by AWS account and cost tag `Proj`, using an IAM role that can access all AWS accounts in the organisation
Costs can be grouped by two dimensions/tags.
The default is Account name (`--group1 AccountName`) and Service (`--group2 Service`).

For examples, costs for December 2022, split by AWS account name and cost tag `Proj`, using an IAM role that can access all AWS accounts in the organisation.
Note that this utility requires tags to be suffixed with `$` to differentiate them from other dimensions.

```
aws-costs --start 2022-12-01 --end 2023-01-01 --tag Proj \
aws-costs --start 2022-12-01 --end 2023-01-01 --group2 'Proj$' \
--assume-role arn:aws:iam::012345678901:role/Organisation-CostExplorer-role \
--granularity monthly --message-mode full
--granularity monthly --output full
```

Use `--message-mode csv` to get a CSV file with the costs.
If you want to import this data into a tool like PowerBI that expects key-value inputs use `--message-mode flat`.
Use `--output csv` to get a CSV file with the costs.
If you want to import this data into a tool like PowerBI that expects key-value inputs use `--output flat`.

More options:
### More options and examples:

```
aws-costs --help
```

Generate a markdown report for costs grouped by `Proj` and `CreatedBy` cost allocation tags, as a CSV:

```
aws-costs --group1 'Proj$' --group2 'CreatedBy$' \
--output full --start 2023-06-16 --end 2023-07-16
```

Generate a day by day report for costs grouped by `Proj` and `CreatedBy` (default granularity is monthly):

```
aws-costs --group1 'Proj$' --group2 'CreatedBy$' \
--output flat --start 2023-06-16 --end 2023-07-16 --granularity daily
```

## Library

```python
Expand Down
Loading

0 comments on commit 431b7bb

Please sign in to comment.