public class InstanceCredentialsProvider extends java.lang.Object implements AwsCredentialsProvider
AwsCredentialsProvider that retrieves (temporary) credentials from the EC2 instance metadata service.
The provider will retrieve and cache the credentials. Before each invocation of InstanceCredentialsProvier#getAwsCredentials(),
the service will check whether the credentials need to be refreshed.
See the Retrieving Security Credentials from Instance Metadata, and AWS Request Signing documentation.
Created by Karel Maesen, Geovise BVBA on 07/02/17.
| Constructor and Description |
|---|
InstanceCredentialsProvider()
Constructs an instance
|
InstanceCredentialsProvider(java.lang.String roleName)
Constructs an instance with the security credentials for the specified IAM role
|
| Modifier and Type | Method and Description |
|---|---|
AwsCredentials |
getAwsCredentials()
Returns the AwsCredentials for this provider
|
public InstanceCredentialsProvider(java.lang.String roleName)
roleName - the name of the IAM role to retrievepublic InstanceCredentialsProvider()
When constructing this instance the instance metadata services will be queried for available role names and the first role will be selected. This is same behavior as the AWS SDK.
public AwsCredentials getAwsCredentials()
getAwsCredentials in interface AwsCredentialsProvider