我们如何在不使用会话的情况下创建 AWS 服务客户端(例如 EC2、Autoscaling),而是直接使用 sahred 凭证,就像在 boto3 中一样。
使用这样的会话有效:
sess := session.New(&aws.Config{
Region: aws.String("us-east-1"),
Credentials: credentials.NewSharedCredentials("", profile),
})
svc := ec2.New(sess)
但是,这不起作用:
svc := ec2.New(&aws.Config{
Region: aws.String("us-east-1"),
Credentials: credentials.NewSharedCredentials("", profile),
})
错误:
无法在 ec2.New 的参数中使用 aws.Config 文字(类型 *aws.Config)作为类型 client.ConfigProvider:*aws.Config 未实现 client.ConfigProvider(缺少 ClientConfig 方法)
如何在没有会话的情况下使用 Go AWS SDK 直接创建客户端?