aws / aws-sdk

Landing page for the AWS SDKs on GitHub
https://aws.amazon.com/tools/
Other
68 stars 12 forks source link

DescribeLogGroupsResponse missing some field (logGroupArn) #669

Closed thangdoominh closed 2 months ago

thangdoominh commented 6 months ago

Describe the issue

I use DescribeLogGroupsCommand with @aws-sdk/client-cloudwatch-logs for discover the list of Log Groups in AWS Cloudwatch. I saw some differences with a document in the response.

This is the example in the AWS Document:

{ // DescribeLogGroupsResponse
  logGroups: [ // LogGroups
    { // LogGroup
      logGroupName: "STRING_VALUE",
      creationTime: Number("long"),
      retentionInDays: Number("int"),
      metricFilterCount: Number("int"),
      arn: "STRING_VALUE",
      storedBytes: Number("long"),
      kmsKeyId: "STRING_VALUE",
      dataProtectionStatus: "ACTIVATED" || "DELETED" || "ARCHIVED" || "DISABLED",
      inheritedProperties: [ // InheritedProperties
        "ACCOUNT_DATA_PROTECTION",
      ],
      logGroupClass: "STANDARD" || "INFREQUENT_ACCESS",
    },
  ],
  nextToken: "STRING_VALUE",
};

My response:

{
  "arn": "arn:aws:logs:ap-southeast-1:*****:log-group:/aws/amazonmq/broker/b-***-***-***-***-***/general:*",
  "region": "ap-southeast-1",
  "logGroupArn": "arn:aws:logs:ap-southeast-1::*****::log-group:/aws/amazonmq/broker/b-***-***-***-***-***/general",
  "storedBytes": 26279***,
  "creationTime": 1670257385***,
  "logGroupName": "/aws/amazonmq/broker/b-***-***-***-***-***/general",
  "logGroupClass": "STANDARD",
  "retentionInDays": 180,
  "metricFilterCount": 0
}

Package version: "@aws-sdk/client-cloudwatch-logs": "^3.478.0"

Links

https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cloudwatch-logs/command/DescribeLogGroupsCommand/

erricc commented 6 months ago

Hi @thangdoominh,

I also got this problem, please update.

Thanks

RanVaknin commented 6 months ago

Hi @thangdoominh and @erricc ,

This arn:* pattern is common when working with policies. Where you want to apply a policy to a log group and all of its child streams (there are multiple Log Streams per log group). My guess is that the LogGroupArn was added specifically to address this issue of customer passing the arn field directly. Since changing arn would have been considered a breaking change, Cloudwatch API team might have added the logGroupArn to address your concerns.

As far as the arn field goes, it is documented and is aligned with Cloudwatch's definition of what an arn should look like: image

As far as the discrepancy in documentation and modeling goes, I can confirm that this is an issue. In this case the Cloudwatch logs service is returning data that is unmodeled. The SDK (and the AWS docs) are directly code generated from that API model defined by the service. You can see that the internal model is in fact missing the LogGroupArn field you are seeing in the response here.

However, It's not clear to me what is stopping you from using the logGroupArn if its present on the response?

I'll create an internal ticket with the service team so they can update their model so that the documentation will get updated.

Thanks, Ran~

V1175654541

thangdoominh commented 6 months ago

I use Typescript for my project. So the interface LogGroup doesn't have the logGroupArn, so I cannot use like image. By your confirmation I already work around it. I will follow up on this issue, thank you

RanVaknin commented 2 months ago

Documentation is now updated 👍 Thanks again! Ran~

github-actions[bot] commented 2 months ago

This issue is now closed.

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.