Ive been trying to get usage data for Ec2 instances for all user values tagged as 'User'. Idk what im doing wrong but i keep getting some type of botocore error. I can't figure out what is wrong with the filter. Appreciate any help
for value in tag_values:
response = ce_client.get_cost_and_usage(
TimePeriod={'Start': '2023-05-05', 'End': '2023-10-10'},
Granularity='MONTHLY',
Metrics=['UsageQuantity'], # blendedcost
Filter={
'Tags': {
'Key': 'User',
'Values': [value]
},
'Dimensions': {'Key': 'SERVICE',
'Values': ['Amazon Elastic Compute Cloud - Compute']
}
}
)
error in this line->
response = ce_client.get_cost_and_usage(
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the GetCostAndUsage operation: Expression has more than one roots. Only one root operator is allowed for each expression: And, Or, Not, Dimensions, Tags, CostCategories
You need to combine your filters with an operator, e.g. using
And
: