How do I access Cost Allocation Tag data from AWS Athena

Viewed 225

I have a Cost and Usage report configured to delivery hourly data to an S3 bucket. I query this using AWS Athena.

The config is attached below. It clearly states that Cost Allocation Tags are included in the report. However, this data doesn't show up in my Athena queries. Nor do I see any columns in the table that relates the Cost Allocation Tags.

I have Cost Allocation Tags activated and they correctly show up in Cost Explorer.

I browsed through the AWS documentation but couldn't find any mention of this.

So, how do I access Cost Allocation Tag data from AWS Athena?

Cost and Usage report configuration Cost Allocation Tags Cost Explorer

1 Answers

Just after posting the question I found the solution.

I created the Cost Allocation Tags later so they weren't included in the Athena table. I had to manually add these columns and it worked after that.

Here is the snippet that fixed it:

ALTER TABLE <reducted>.<reducted> ADD COLUMNS (resource_tags_aws_cloudformation_stack_id string, resource_tags_aws_cloudformation_stack_name string)

I managed to find the columns names from the billing-create-table.sql in the S3 bucket where the reports go.

Related