Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cost Explorer Api. Can't group request by Tag. #5112

Closed
girolamodaschio opened this issue Dec 15, 2023 · 2 comments
Closed

Cost Explorer Api. Can't group request by Tag. #5112

girolamodaschio opened this issue Dec 15, 2023 · 2 comments
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@girolamodaschio
Copy link

Describe the bug

The current version of the AWS SDK for Go lacks the capability to group AWS Cost Explorer responses by tag.
This feature is crucial for users who need to analyse and manage costs efficiently based on specific tags associated with their AWS resources.

Expected Behavior

The SDK should provide a method or functionality that allows users to group Cost Explorer responses by tag, enabling them to gain insights into costs associated with specific resource categories.
Instead, it returns a TAGS$ as the key.

Current Behavior

The snippet code as written below returns
this structure of data:



  Estimated: false,
  Groups: [{
      Keys: ["TAGS$"],
      Metrics: {
        BlendedCost: {
          Amount: "21.4009595589",
          Unit: "USD"
        }
      }
    }],
  TimePeriod: {
    End: "2023-11-16",
    Start: "2023-11-15"
  },
  Total: {

  }
}

Reproduction Steps

func getCostByTag(session *session.Session) (*costexplorer.GetCostAndUsageOutput, error) {
	svc := costexplorer.New(session)

	resp, err := svc.GetCostAndUsage(&costexplorer.GetCostAndUsageInput{
		Metrics:     []*string{aws.String("BlendedCost")},
		TimePeriod:  getDates(),
		Granularity: aws.String("DAILY"),
		GroupBy: []*costexplorer.GroupDefinition{
			&costexplorer.GroupDefinition{
				Key:  aws.String("TAGS"),
				Type: aws.String("TAG"),
			},
		},
	})

	if err != nil {
		fmt.Println("Error getting cost data:", err)
		return nil, err
	}

	return resp, nil
}

Possible Solution

I'm trying to accomplish what's written here:
// When you group by the TAG type and include a valid tag key, you get all tag
// values, including empty strings.
GroupBy []*GroupDefinition type:"list"

https://github.com/aws/aws-sdk-go/blob/v1.49.2/service/costexplorer/api.go#L7782-L7847

Additional Information/Context

No response

SDK version used

github.com/aws/aws-sdk-go v1.49.2

Environment details (Version of Go (go version)? OS name and version, etc.)

go version go1.21.4 darwin/arm64

@girolamodaschio girolamodaschio added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 15, 2023
@girolamodaschio
Copy link
Author

Was a futile mistake on the groupby.
Adding the correct tag fixed it.

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant