Skip to content

Commit

Permalink
Merge branch 'develop' into fix/845-exclude-component-dropdown-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mlabouardy authored Jun 14, 2023
2 parents d4809be + 96d8518 commit e51d420
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions providers/aws/cloudwatch/dashboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func Dashboards(ctx context.Context, client ProviderClient) ([]Resource, error)
return resources, err
}

for _, dashboard := range output.DashboardEntries {
for index, dashboard := range output.DashboardEntries {
outputTags, err := cloudWatchClient.ListTagsForResource(ctx, &cloudwatch.ListTagsForResourceInput{
ResourceARN: dashboard.DashboardArn,
})
Expand All @@ -43,14 +43,16 @@ func Dashboards(ctx context.Context, client ProviderClient) ([]Resource, error)
}
}

cost := calculateDashboardCost(index + 1)

resources = append(resources, Resource{
Provider: "AWS",
Account: client.Name,
Service: "CloudWatch Dashboard",
ResourceId: *dashboard.DashboardArn,
Region: client.AWSClient.Region,
Name: *dashboard.DashboardName,
Cost: 0,
Cost: cost,
Tags: tags,
FetchedAt: time.Now(),
Link: fmt.Sprintf("https://%s.console.aws.amazon.com/cloudwatch/home?region=%s#dashboards:name=%s", client.AWSClient.Region, client.AWSClient.Region, *dashboard.DashboardName),
Expand All @@ -73,3 +75,13 @@ func Dashboards(ctx context.Context, client ProviderClient) ([]Resource, error)

return resources, nil
}

func calculateDashboardCost(dashboardCount int) float64 {
freeDashboards := 3
cost := 0.0

if dashboardCount > freeDashboards {
cost = 3.0
}
return cost
}

0 comments on commit e51d420

Please sign in to comment.