createSts(); $sourceIdentity = $stsClient->getCallerIdentity(); $sourceArn = $sourceIdentity['Arn']; $assumeRolePolicy = <<createIam(); self::$roleName = 'php-integration-' . round(microtime(true) * 1000); $result = $iamClient->createRole([ 'AssumeRolePolicyDocument' => $assumeRolePolicy, 'RoleName' => self::$roleName, ]); self::$roleArn = $result['Role']['Arn']; $iamClient->waitUntil('RoleExists', ['RoleName' => self::$roleName]); } /** * @AfterFeature @credentials */ public static function teardownIamRole() { $client = self::getSdk()->createIam(); $client->deleteRole([ 'RoleName' => self::$roleName ]); } /** * @Given I have a credentials file with session name :value */ public function iHaveACredentialsFile($sessionName) { $iamClient = self::getSdk()->createIam(); $creds = $iamClient->getCredentials()->wait(); $sourceKeyId = $creds->getAccessKeyId(); $sourceAccessKey = $creds->getSecretKey(); $sourceToken = $creds->getSecurityToken(); $roleArn = self::$roleArn; $ini = <<credentials = CredentialProvider::ini( 'assumeInteg', self::$credentialsFile ); } /** * @Given I have an sts client */ public function iHaveAnStsClient() { $this->client = self::getSdk()->createSts([ 'credentials' => $this->credentials ]); } /** * @When I call GetCallerIdentity */ public function iCallGetCallerIdentity() { //Assume role should exist, but may not yet be assumable. $maxAttempts = 10; $attempts = 0; do { try { $this->result = $this->client->getCallerIdentity(); } catch (\Exception $e) { $attempts++; sleep(2); continue; } break; } while ($attempts < $maxAttempts); } /** * @Then the value at :key should contain :value */ public function theValueAtShouldBeA($key, $value) { $this->assertInstanceOf(Result::class, $this->result); $this->assertStringContainsString($value, $this->result->search($key)); } }