无法使用AWS Golang SDK获取有关DynamoDB备份的信息。

huangapple go评论99阅读模式
英文:

Can't get information about DynamoDB backups using AWS Golang SDK

问题

我需要获取有关 DynamoDB 表备份的信息。
假设我在仪表板中列出了备份:
无法使用AWS Golang SDK获取有关DynamoDB备份的信息。

然而,我无法使用 Golang SDK 获取任何备份:

import (
...
"github.com/aws/aws-sdk-go/service/dynamodb"
...
)
...
svc := dynamodb.New(c.providerConfig.Session, regionConfig)
response, err := svc.ListBackupsWithContext(ctx, input)
// response.BackupSummaries is empty

backupArn := <从仪表板中选择任何一个备份的 ARN>
output, _ := svc.DescribeBackupWithContext(ctx, &dynamodb.DescribeBackupInput{BackupArn: &backupArn})
// 即使通过指定 ARN 请求备份,我们也没有运气
// output.BackupDescription is nil

其他函数(1. 使用 ListTablesPagesWithContext 获取表 2. 使用 DescribeContinuousBackups 获取连续备份描述)都可以正常工作。唯一无法获取的是(非连续)备份。

有人可以解释一下为什么我在仪表板中列出 DynamoDB 表备份,但仍然得到空响应吗?

英文:

I need to get information about DynamoDB tables backups.
So lets say I have backups listed in dashboard:
无法使用AWS Golang SDK获取有关DynamoDB备份的信息。

I can't get any backups using Golang SDK though:

import (
...
&quot;github.com/aws/aws-sdk-go/service/dynamodb&quot;
...
)
...
svc := dynamodb.New(c.providerConfig.Session, regionConfig)
response, err := svc.ListBackupsWithContext(ctx, input)
// response.BackupSummaries is empty

backupArn := &lt;ARN of any of the backups from dashboard&gt;
output, _ := svc.DescribeBackupWithContext(ctx, &amp;dynamodb.DescribeBackupInput{BackupArn: &amp;backupArn})
// even with requesting for a backup by specific ARN we have no luck
// output.BackupDescription is nil

Other functions (1. getting tables with ListTablesPagesWithContext 2. getting continuous backup description with DescribeContinuousBackups) works perfectly. The only thing i can't get (non-continuous) backups.

Can someone help with explanation why I keep getting empty responses though DynamoDB table backups listed in dashboard?

答案1

得分: 3

ListBackups 的默认设置是 BackupType:USER。这意味着当你调用 ListBackups 时,只会返回手动创建的备份。由于你的备份由 AWS Backup 维护,你应该将 BackupType 参数设置为 ALLSYSTEM

希望能对你有所帮助。

注意,我尝试修复了你的代码,但 Go 不是我的强项(正确的概率为50% 无法使用AWS Golang SDK获取有关DynamoDB备份的信息。 )。

backupArn := <仪表板上任何备份的ARN>
backupType := "ALL"
output, _ := svc.DescribeBackupWithContext(ctx, &dynamodb.DescribeBackupInput{BackupArn: &backupArn, BackupType: &backupType})
英文:

The default settings for ListBackups is BackupType:USER. This means when you call ListBackups you are only being returned ones that are manually created. As your backups are maintained by AWS Backup, you should set the BackupType parameter to either ALL or SYSTEM.

Hope that helps.

Note I attempted to fix your code, but Go is not my strong point (50% chance of being correct 无法使用AWS Golang SDK获取有关DynamoDB备份的信息。 )

backupArn := &lt;ARN of any of the backups from dashboard&gt;
backupType:= &#39;ALL&#39;
output, _ := svc.DescribeBackupWithContext(ctx, &amp;dynamodb.DescribeBackupInput{BackupArn: &amp;backupArn, BackupType: &amp;backupType})

huangapple
  • 本文由 发表于 2022年9月14日 20:50:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/73717146.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定