Search in sources :

Example 6 with StsClient

use of software.amazon.awssdk.services.sts.StsClient in project aws-doc-sdk-examples by awsdocs.

the class GetAccessKeyInfo method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <accessKeyId> \n\n" + "Where:\n" + "    accessKeyId - the identifier of an access key (for example, XXXXX3JWY3BXW7POHDLA). \n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String accessKeyId = args[0];
    Region region = Region.US_EAST_1;
    StsClient stsClient = StsClient.builder().region(region).build();
    getKeyInfo(stsClient, accessKeyId);
    stsClient.close();
}
Also used : StsClient(software.amazon.awssdk.services.sts.StsClient) Region(software.amazon.awssdk.regions.Region)

Example 7 with StsClient

use of software.amazon.awssdk.services.sts.StsClient in project aws-doc-sdk-examples by awsdocs.

the class GetCallerIdentity method main.

public static void main(String[] args) {
    Region region = Region.US_EAST_1;
    StsClient stsClient = StsClient.builder().region(region).build();
    getCallerId(stsClient);
    stsClient.close();
}
Also used : StsClient(software.amazon.awssdk.services.sts.StsClient) Region(software.amazon.awssdk.regions.Region)

Example 8 with StsClient

use of software.amazon.awssdk.services.sts.StsClient in project iep by Netflix.

the class AwsClientFactory method createAssumeRoleProvider.

private AwsCredentialsProvider createAssumeRoleProvider(Config cfg, AwsCredentialsProvider p) {
    final String arn = cfg.getString("role-arn");
    final String name = cfg.getString("role-session-name");
    final STSClient stsClient = STSClient.builder().credentialsProvider(p).region(Region.of(region)).build();
    final AssumeRoleRequest request = AssumeRoleRequest.builder().roleArn(arn).roleSessionName(name).build();
    return StsAssumeRoleCredentialsProvider.builder().stsClient(stsClient).refreshRequest(request).build();
}
Also used : AssumeRoleRequest(software.amazon.awssdk.services.sts.model.AssumeRoleRequest) STSClient(software.amazon.awssdk.services.sts.STSClient)

Aggregations

StsClient (software.amazon.awssdk.services.sts.StsClient)6 Region (software.amazon.awssdk.regions.Region)5 AssumeRoleRequest (software.amazon.awssdk.services.sts.model.AssumeRoleRequest)4 STSClient (software.amazon.awssdk.services.sts.STSClient)2 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 AwsSessionCredentials (software.amazon.awssdk.auth.credentials.AwsSessionCredentials)1 AwsCredentialsProvider (software.amazon.awssdk.core.auth.AwsCredentialsProvider)1 S3Client (software.amazon.awssdk.services.s3.S3Client)1 ListObjectsRequest (software.amazon.awssdk.services.s3.model.ListObjectsRequest)1 ListObjectsResponse (software.amazon.awssdk.services.s3.model.ListObjectsResponse)1 S3Object (software.amazon.awssdk.services.s3.model.S3Object)1 AssumeRoleResponse (software.amazon.awssdk.services.sts.model.AssumeRoleResponse)1 Credentials (software.amazon.awssdk.services.sts.model.Credentials)1 StsException (software.amazon.awssdk.services.sts.model.StsException)1