Skip to content

Commit

Permalink
removed unneccesary comments
Browse files Browse the repository at this point in the history
Signed-off-by: bishal7679 <bishalhnj127@gmail.com>
  • Loading branch information
bishal7679 committed Oct 9, 2023
1 parent eeef8dc commit 66b6a6c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions providers/aws/s3/buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Buckets(ctx context.Context, client ProviderClient) ([]Resource, error) {
ServiceCode: aws.String("AmazonS3"),
Filters: []types.Filter{
{
Field: aws.String("regionCode"), // Filter by region
Field: aws.String("regionCode"),
Value: aws.String(client.AWSClient.Region),
Type: types.FilterTypeTermMatch,
},
Expand All @@ -51,14 +51,12 @@ func Buckets(ctx context.Context, client ProviderClient) ([]Resource, error) {
return resources, err
}

// ---------------------------------------------------------------
output, err := s3Client.ListBuckets(context.Background(), &config)
if err != nil {
return resources, err
}

for _, bucket := range output.Buckets {
// metrics for bucket size
metricsBucketSizebytesOutput, err := cloudwatchClient.GetMetricStatistics(ctx, &cloudwatch.GetMetricStatisticsInput{
StartTime: aws.Time(utils.BeginningOfMonth(time.Now())),
EndTime: aws.Time(time.Now()),
Expand Down Expand Up @@ -86,8 +84,6 @@ func Buckets(ctx context.Context, client ProviderClient) ([]Resource, error) {

sizeInTB := ConvertBytesToTerabytes(int64(bucketSize))

// metrics for bucket usage

metricsUsageOutput, err := cloudwatchClient.GetMetricStatistics(ctx, &cloudwatch.GetMetricStatisticsInput{
StartTime: aws.Time(utils.BeginningOfMonth(time.Now())),
EndTime: aws.Time(time.Now()),
Expand All @@ -113,12 +109,11 @@ func Buckets(ctx context.Context, client ProviderClient) ([]Resource, error) {
if metricsUsageOutput != nil && len(metricsUsageOutput.Datapoints) > 0 {
requestCount = *metricsUsageOutput.Datapoints[0].Sum
}
// requestCost := (requestCount / 1000) * 0.0004

monthlyCost := 0.0

storageCharges := awsUtils.GetCost(priceMap["AWS-S3-Storage"], sizeInTB*1024) // charges per GB
requestCharges := awsUtils.GetCost(priceMap["AWS-S3-Requests"], requestCount/1000) // charges per 1000 request
storageCharges := awsUtils.GetCost(priceMap["AWS-S3-Storage"], sizeInTB*1024)
requestCharges := awsUtils.GetCost(priceMap["AWS-S3-Requests"], requestCount/1000)
monthlyCost = storageCharges + requestCharges
tagsResp, err := s3Client.GetBucketTagging(context.Background(), &s3.GetBucketTaggingInput{
Bucket: bucket.Name,
Expand Down

0 comments on commit 66b6a6c

Please sign in to comment.