Skip to content

Commit

Permalink
Optionally specify * to handle unknown proj-tag-names
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed Jul 4, 2024
1 parent 313e687 commit fccace4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion aws_project_costs/project-cost-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions aws_project_costs/project_costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit fccace4

Please sign in to comment.