[v9.3.x] CloudWatch: Cross-account querying support (#59389)
* add cross-account querying support * fix tests
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user