我遇到了问题How to switch between multiple accounts with AWS SDK。但是它指的是同一AWS账户上的不同账户配置文件。
使用.NET SDK,我似乎无法完全指向另一个AWS。我所有的流量都流向了我的工作帐户。我希望流量指向另一个AWS账户。我该怎么办?
我从这里出发:
AWSCredentials awsCreds;
CredentialProfile profile;
var netSdkCredsFile = new NetSDKCredentialsFile();
if (netSdkCredsFile.TryGetProfile("profile", out profile))
{
awsCreds = AWSCredentialsFactory.GetAWSCredentials(profile, netSdkCredsFile, true);
}
else
throw new Exception("no profile");
client = new AmazonS3Client(awsCreds, bucketRegion);
对此没有成功:
_client = new AmazonS3Client("{access key}", "{secret access key}", new AmazonS3Config { ServiceURL= "{s3 bucket url}" });