Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ruggieroguida/6f799802cd7eddf3ff08bbb186876af9 to your computer and use it in GitHub Desktop.
Save ruggieroguida/6f799802cd7eddf3ff08bbb186876af9 to your computer and use it in GitHub Desktop.
resp = iam_client.get_cost_and_usage({
time_period: {
start: start_date,
end: end_date,
},
granularity: "MONTHLY",
filter: {
and: [
{
tags: {
key: "MCTOrganization",
values: [mctorg],
match_options: ["EQUALS"],
},
},
{
dimensions: {
key: "SERVICE",
values: ["Amazon Elastic Compute Cloud - Compute"],
match_options: ["EQUALS"],
},
},
{
not: {
tags: {
key: "MCTUser",
values: ["mctsupport"],
match_options: ["EQUALS"],
},
},
},
],
},
metrics: ["BLENDED_COST"],
group_by: [
{
type: "TAG",
key: "MCTProject",
},
{
type: "DIMENSION", # accepts DIMENSION, TAG, COST_CATEGORY
key: "PURCHASE_TYPE",
},
],
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment