public class InstanceProfileCredentialsProvider extends Object implements AWSCredentialsProvider, Closeable
When using InstanceProfileCredentialsProvider
with asynchronous refreshing it is
strongly recommended to explicitly call InstanceProfileCredentialsProvider.close()
to release the async thread.
The provider is configured with the default Instance Metadata Service endpoint. You can override the endpoint value by setting a valid URI as the value of the
Constructor and Description |
---|
InstanceProfileCredentialsProvider()
Deprecated.
for the singleton method
InstanceProfileCredentialsProvider.getInstance() . |
InstanceProfileCredentialsProvider(boolean refreshCredentialsAsync)
Spins up a new thread to refresh the credentials asynchronously if
refreshCredentialsAsync is set to true, otherwise the credentials will be
refreshed from the instance metadata service synchronously,
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
static InstanceProfileCredentialsProvider |
createAsyncRefreshingProvider(boolean eagerlyRefreshCredentialsAsync)
Spins up a new thread to refresh the credentials asynchronously.
|
protected void |
finalize() |
AWSCredentials |
getCredentials()
Returns AWSCredentials which the caller can use to authorize an AWS request.
|
static InstanceProfileCredentialsProvider |
getInstance()
Returns a singleton
InstanceProfileCredentialsProvider that does not refresh credentials asynchronously. |
void |
refresh()
Forces this credentials provider to refresh its credentials.
|
@Deprecated public InstanceProfileCredentialsProvider()
InstanceProfileCredentialsProvider.getInstance()
.public InstanceProfileCredentialsProvider(boolean refreshCredentialsAsync)
It is strongly recommended to reuse instances of this credentials provider, especially when async refreshing is used since a background thread is created.
refreshCredentialsAsync
- true if credentials needs to be refreshed asynchronously else
false.public static InstanceProfileCredentialsProvider createAsyncRefreshingProvider(boolean eagerlyRefreshCredentialsAsync)
It is strongly recommended to reuse instances of this credentials provider, especially when async refreshing is used since a background thread is created.
eagerlyRefreshCredentialsAsync
- when set to false will not attempt to refresh credentials asynchronously
until after a call has been made to InstanceProfileCredentialsProvider.getCredentials()
- ensures that
BaseCredentialsFetcher.getCredentials()
is only hit when this CredentialProvider is actually requiredpublic static InstanceProfileCredentialsProvider getInstance()
InstanceProfileCredentialsProvider
that does not refresh credentials asynchronously.
See InstanceProfileCredentialsProvider(boolean)
or InstanceProfileCredentialsProvider.createAsyncRefreshingProvider(boolean)
for
asynchronous credentials refreshing.
protected void finalize() throws Throwable
public AWSCredentials getCredentials()
getCredentials
in interface AWSCredentialsProvider
AmazonClientException
- if SDKGlobalConfiguration.isEc2MetadataDisabled()
is truepublic void refresh()
AWSCredentialsProvider
refresh
in interface AWSCredentialsProvider
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2024. All rights reserved.