[v9.3.x] CloudWatch: Cross-account querying support (#59389)

* add cross-account querying support

* fix tests
This commit is contained in:
Erik Sundell
2022-11-28 14:21:34 +01:00
committed by GitHub
parent 426fab32eb
commit c652135724
100 changed files with 3960 additions and 488 deletions
@@ -5,8 +5,15 @@ import (
"net/url"
)
const useLinkedAccountsId = "all"
type ResourceRequest struct {
Region string
Region string
AccountId *string
}
func (r *ResourceRequest) ShouldTargetAllAccounts() bool {
return r.AccountId != nil && *r.AccountId == useLinkedAccountsId
}
func getResourceRequest(parameters url.Values) (*ResourceRequest, error) {
@@ -14,9 +21,24 @@ func getResourceRequest(parameters url.Values) (*ResourceRequest, error) {
Region: parameters.Get("region"),
}
accountId := parameters.Get("accountId")
if accountId != "" {
request.AccountId = &accountId
}
if request.Region == "" {
return nil, fmt.Errorf("region is required")
}
return request, nil
}
type LogsRequest struct {
Limit int64
AccountId, LogGroupNamePrefix, LogGroupNamePattern *string
IsCrossAccountQueryingEnabled bool
}
func (r LogsRequest) IsTargetingAllAccounts() bool {
return *r.AccountId == useLinkedAccountsId
}