code: public static AWSCredentialsProvider getInstance(final String credentialAccessKey, final String credentialSecretKey,
                                                       final Resource credentialPropertiesFile,
                                                       final String profilePath, final String profileName) {
  
          LOGGER.debug("Attempting to locate AWS credentials...");
  
          val chain = new ArrayList<AWSCredentialsProvider>();
          chain.add(new InstanceProfileCredentialsProvider(false));
  
          if (credentialPropertiesFile != null) {
              try {
                  val f = credentialPropertiesFile.getFile();
                  chain.add(new PropertiesFileCredentialsProvider(f.getCanonicalPath()));
              } catch (final Exception e) {
                  LOGGER.error(e.getMessage(), e);
              }
          }
          if (StringUtils.isNotBlank(profilePath) && StringUtils.isNotBlank(profileName)) {
              addProviderToChain(nothing -> {
                  chain.add(new ProfileCredentialsProvider(profilePath, profileName));
                  return null;
              });
          }
          addProviderToChain(nothing -> {
              chain.add(new SystemPropertiesCredentialsProvider());
              return null;
          });
  
          addProviderToChain(nothing -> {
              chain.add(new EnvironmentVariableCredentialsProvider());
              return null;
          });
  
          addProviderToChain(nothing -> {
              chain.add(new ClasspathPropertiesFileCredentialsProvider("awscredentials.properties"));
              return null;
          });
  
          if (StringUtils.isNotBlank(credentialAccessKey) && StringUtils.isNotBlank(credentialSecretKey)) {
              addProviderToChain(nothing -> {
                  val credentials = new BasicAWSCredentials(credentialAccessKey, credentialSecretKey);
                  chain.add(new AWSStaticCredentialsProvider(credentials));
                  return null;
              });
          }
  
          LOGGER.debug("AWS chained credential providers are configured as [{}]", chain);
          return new ChainingAWSCredentialsProvider(chain);
      }
docs: Gets instance.
  
  @param credentialAccessKey      the credential access key
  @param credentialSecretKey      the credential secret key
  @param credentialPropertiesFile the credential properties file
  @param profilePath              the profile path
  @param profileName              the profile name
  @return the instance