STS client

This page contains some example usage for STS. There are other resources that explain authentication and configuration.

The STS package could be installed with Composer.

composer require async-aws/core

Usage

Retrieve current Account

use AsyncAws\Core\Sts\StsClient; $sts = new StsClient(); $result = $sts->getCallerIdentity(); echo 'current Account:' . $result->getAccount();

Retrieve current Account

use AsyncAws\Core\Sts\Input\AssumeRoleRequest; use AsyncAws\Core\Sts\StsClient; $sts = new StsClient(); $result = $sts->assumeRole(new AssumeRoleRequest([ 'RoleArn' => 'arn:aws::iam::123456789012:role/demo', 'RoleSessionName' => 'demo-session', 'DurationSeconds' => 3600, ])); echo 'AccessKeyId:' . $result->getCredentials()->getAccessKeyId().PHP_EOL; echo 'SecretAccessKey:' . $result->getCredentials()->getSecretAccessKey().PHP_EOL; echo 'SessionToken:' . $result->getCredentials()->getSessionToken();