JavaScript is disabled on your browser.
Skip navigation links

AWS SDK for Java 1.x API Reference - 1.12.793

We announced the upcoming end-of-support for AWS SDK for Java (v1). We recommend that you migrate to AWS SDK for Java v2. For dates, additional details, and information on how to migrate, please refer to the linked announcement.
com.amazonaws.auth

Class InstanceProfileCredentialsProvider

  • All Implemented Interfaces:
    AWSCredentialsProvider, Closeable, AutoCloseable


    public class InstanceProfileCredentialsProvider
    extends Object
    implements AWSCredentialsProvider, Closeable 
    Credentials provider implementation that loads credentials from the Amazon EC2 Instance Metadata Service (IMDS).

    When using InstanceProfileCredentialsProvider with asynchronous refreshing it is strongly recommended to explicitly call 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

    1. com.amazonaws.sdk.ec2MetadataServiceEndpointOverride system property or
    2. AWS_EC2_METADATA_SERVICE_ENDPOINT environment value

    • Constructor Detail

      • InstanceProfileCredentialsProvider

        @Deprecated
        public InstanceProfileCredentialsProvider()
        Deprecated. for the singleton method getInstance().
      • InstanceProfileCredentialsProvider

        public 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,

        It is strongly recommended to reuse instances of this credentials provider, especially when async refreshing is used since a background thread is created.

        Parameters:
        refreshCredentialsAsync - true if credentials needs to be refreshed asynchronously else false.
    • Method Detail

      • createAsyncRefreshingProvider

        public static InstanceProfileCredentialsProvider createAsyncRefreshingProvider(boolean eagerlyRefreshCredentialsAsync)
        Spins up a new thread to refresh the credentials asynchronously.

        It is strongly recommended to reuse instances of this credentials provider, especially when async refreshing is used since a background thread is created.

        Parameters:
        eagerlyRefreshCredentialsAsync - when set to false will not attempt to refresh credentials asynchronously until after a call has been made to getCredentials() - ensures that BaseCredentialsFetcher.getCredentials() is only hit when this CredentialProvider is actually required
      • getCredentials

        public AWSCredentials getCredentials()
        Returns AWSCredentials which the caller can use to authorize an AWS request. Each implementation of AWSCredentialsProvider can chose its own strategy for loading credentials. For example, an implementation might load credentials from an existing key management system, or load new credentials when credentials are rotated.
        Specified by:
        getCredentials in interface AWSCredentialsProvider
        Returns:
        AWSCredentials which the caller can use to authorize an AWS request.
        Throws:
        AmazonClientException - if SDKGlobalConfiguration.isEc2MetadataDisabled() is true
      • refresh

        public void refresh()
        Description copied from interface: AWSCredentialsProvider
        Forces this credentials provider to refresh its credentials. For many implementations of credentials provider, this method may simply be a no-op, such as any credentials provider implementation that vends static/non-changing credentials. For other implementations that vend different credentials through out their lifetime, this method should force the credentials provider to refresh its credentials.
        Specified by:
        refresh in interface AWSCredentialsProvider
Skip navigation links

AltStyle によって変換されたページ (->オリジナル) /