CloudWatch: Migrate to aws-sdk-go-v2 (#103106)

* Cloudwatch: Migrate to aws-sdk-go-v2 (#99643)
* CloudWatch: use PDC fix from new grafana-aws-sdk
This commit is contained in:
Nathan Vērzemnieks
2025-04-01 10:03:06 +02:00
committed by GitHub
parent 3e15459d20
commit a65cc0df93
60 changed files with 1497 additions and 1607 deletions
+9 -8
View File
@@ -5,12 +5,13 @@ import (
"encoding/json"
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/aws/aws-sdk-go/service/cloudwatch/cloudwatchiface"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/cloudwatch"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/backend/log"
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -22,7 +23,7 @@ func TestQuery_AnnotationQuery(t *testing.T) {
})
var client fakeCWAnnotationsClient
NewCWClient = func(sess *session.Session) cloudwatchiface.CloudWatchAPI {
NewCWClient = func(aws.Config) models.CWClient {
return &client
}
@@ -53,8 +54,8 @@ func TestQuery_AnnotationQuery(t *testing.T) {
assert.Equal(t, &cloudwatch.DescribeAlarmsForMetricInput{
Namespace: aws.String("custom"),
MetricName: aws.String("CPUUtilization"),
Statistic: aws.String("Average"),
Period: aws.Int64(300),
Statistic: "Average",
Period: aws.Int32(300),
}, client.calls.describeAlarmsForMetric[0])
})
@@ -86,7 +87,7 @@ func TestQuery_AnnotationQuery(t *testing.T) {
require.Len(t, client.calls.describeAlarms, 1)
assert.Equal(t, &cloudwatch.DescribeAlarmsInput{
MaxRecords: aws.Int64(100),
MaxRecords: aws.Int32(100),
ActionPrefix: aws.String("some_action_prefix"),
AlarmNamePrefix: aws.String("some_alarm_name_prefix"),
}, client.calls.describeAlarms[0])