尝试在 AWSgosdk 的帮助下在 TerraTest 中调用 CloudWatch LoggroupName 和 L



在terratest中,我想调用aws cloud watch特定的日志组名称和下面的日志流名称,代码来自git hub,但不知道如何调用特定的日志组和日志流

https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/go/example_code/cloudwatch/CloudWatchGetLogEvents.go

试试这样的事情

c := aws.NewCloudWatchLogsClient(t, awsRegion)
t.Run("logStreamExists", func(t *testing.T) {
        output, err := c.DescribeLogStreams(&cloudwatchlogs.DescribeLogStreamsInput{
            LogGroupName: &logGroupName,
        })
        if err != nil {
            assert.Fail(t, "Failed to get log streams")
        }
    var names []string
    for _, element := range output.LogStreams {
        names = append(names, *element.LogStreamName)
    }
    assert.Contains(t, names, logStreamName)
})

相关内容

  • 没有找到相关文章

最新更新