Can we get the cost of a singe lambda function using GetCostAndUsageWithResources?

28 views Asked by At

I am trying to find the cost of a single lambda function. The document on GetCostAndUsageWithResources doesn't specify which services arns or ids we can put while filterting through "RESOURCE_ID".

I tried the following code using boto3's get_cost_and_usage_with_resources but all I recieved was zero cost being incurred.

import boto3

ce_client = boto3.client("ce")

response = ce_client.get_cost_and_usage_with_resources(
    TimePeriod={"Start": <some-start-date>, "End": <some-end-date>,
    Granularity="DAILY",
    Filter={
        "Dimensions": {
            "Key": "RESOURCE_ID",
            "Values": [<my-lambda-arn>]
        }
    },
    Metrics=["UnblendedCost"],
)

print(response)

So, what I want to ask are these two questions:

  1. Can GetCostAndUsageWithResources be used to find the cost of single lambda function?
  2. If not, then, how can we get the cost of a single lambda function by using its name or arn?
0

There are 0 answers