diff --git a/aws_project_costs/project-cost-schema.json b/aws_project_costs/project-cost-schema.json index bfb466f..ed0bfba 100644 --- a/aws_project_costs/project-cost-schema.json +++ b/aws_project_costs/project-cost-schema.json @@ -5,7 +5,7 @@ "type": "object", "properties": { "proj-tag-names": { - "description": "A mapping of AWS project tags to the canonical project name", + "description": "A mapping of AWS project tags to the canonical project name. Optionally use '*' to map unknown tags to a defined project name", "type": "object", "additionalProperties": { "type": "string", diff --git a/aws_project_costs/project_costs.py b/aws_project_costs/project_costs.py index 0f255a4..9d96752 100644 --- a/aws_project_costs/project_costs.py +++ b/aws_project_costs/project_costs.py @@ -82,9 +82,12 @@ def _shared_account( project_tag = costs_tag[5:] if project_tagname and project_tag and (project_tag not in shared_tag_values): - if project_tag not in proj_tag_names_map: + if project_tag in proj_tag_names_map: + project_name = proj_tag_names_map[project_tag] + elif "*" in proj_tag_names_map: + project_name = proj_tag_names_map["*"] + else: raise ValueError(f"{project_tag} is not in proj-tag-names") - project_name = proj_tag_names_map[project_tag] rows.append( ( start.date().isoformat(),