Cost explorer boto3 cost and usage without specific tag
How could I apply filter for cost and usage report using boto3. I want to search for all entitites that do not have specific tag.
In cost explorer UI you could specify NoTag and choose the tag you want.
Should I just pass empty value for tag name?
{
'Tags': {
'Key': 'some_tag',
'Values': '',
}
I'm trying to figure out if you are trying to use the Cost Explorer api or if you are trying to query your cost and utilization report. Those are two different things.
You could apply a tag with an empty value. You will then have to enable the tag as a Cost Allocation Tag in order for the tag to show in your cost and usage report (CUR). Once added the tag will create a column in your CUR report named 'resource_tags_user_some_tag'. This will happen within 24 hours. You would then be able to view resources which do not have a value within this column.
I would also recommend creating the CUR/Athena integration to easily query your CUR data. Please note there is a small charge for this as it creates infrastructure to hydrate the Athena table.
Relevant questions
How to tag unlimited CpuCredits for Cost Explorer?
asked 2 months agoCost Explorer for Lambda@Edge
Accepted Answerasked a year agoAccount name changes are not reflected in Cost Explorer
asked 2 months agoAWS Cost Explorer Unblended cost does not match CUR report unblended cost
asked a month agoCost explorer boto3 cost and usage without specific tag
asked 5 months agoDisable AWS Cost Explorer permissions
asked 4 months agoHow is aws cost explorer calculate report for EC2 instances by billing tag?
asked 3 years agoCost explorer boto3 "Charge type"
asked 5 months agoHow to disable Cost Explorer?
asked 3 months agocost explorer for August not showing costs by tags
asked 2 years ago
Not sure about your json method, but I have something similar when checking for Backups on ebs volumes.
if tag'Key' == 'Backup' and tag'Value' == '' ##Key name exists but value is null. print('Backup Key found, but value is null.')
But to answer your question, yes, I used two single quotes to get the null values.