Amazon web services 如何在新的AWS GO SDK-V2中扮演跨帐户访问的角色
继去年12月24日GO SDK-v2 RC之后,我不知道如何创建配置以在不同的aws帐户中承担角色。我找不到任何文档或示例,尝试使用“config.WithAssumeRoleRedentialsOptions”或“stscreds.NewAssumeRoleProvider”,但没有任何结果。有没有人有这样的例子或指南?以下是方法:Amazon web services 如何在新的AWS GO SDK-V2中扮演跨帐户访问的角色,amazon-web-services,go,sdk,assume-role,Amazon Web Services,Go,Sdk,Assume Role,继去年12月24日GO SDK-v2 RC之后,我不知道如何创建配置以在不同的aws帐户中承担角色。我找不到任何文档或示例,尝试使用“config.WithAssumeRoleRedentialsOptions”或“stscreds.NewAssumeRoleProvider”,但没有任何结果。有没有人有这样的例子或指南?以下是方法: ctx := context.TODO() cfg, err := config.LoadDefaultConfig(ctx,
ctx := context.TODO()
cfg, err := config.LoadDefaultConfig(ctx,
config.WithRegion("us-east-1"),
//config.WithClientLogMode(aws.LogSigning),
)
if err != nil {
log.Fatal(err)
}
stsClient := sts.NewFromConfig(cfg)
provider := stscreds.NewAssumeRoleProvider(stsClient, roleARN)
cfg.Credentials = aws.NewCredentialsCache(provider)
// without the following, I'm getting an error message: api error SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided.
creds, err := cfg.Credentials.Retrieve(context.Background())
if err != nil {
log.Fatal(err)
}