一旦你有了Credentials
,你就创建了一个BasicSessionCredentials
对象并将它传递给AmazonCloudFormationClient
. 例如:
// Package the temporary security credentials as
// a BasicSessionCredentials object, for an Amazon S3 client object to use.
BasicSessionCredentials basicSessionCredentials = new BasicSessionCredentials(
sessionCredentials.getAccessKeyId(),
sessionCredentials.getSecretAccessKey(),
sessionCredentials.getSessionToken());
// The following will be part of your less trusted code. You provide temporary security
// credentials so it can send authenticated requests to AWS CloudFormation.
AmazonCloudFormationClient client = new AmazonCloudFormationClient(basicSessionCredentials);
我希望这会有所帮助!