public static AwsCredentialsProvider getInstance(final String credentialAccessKey, final String credentialSecretKey,
                                                     final String profilePath, final String profileName) {

        LOGGER.debug("Attempting to locate AWS credentials...");
        val chain = new ArrayList<AwsCredentialsProvider>();
        addProviderToChain(nothing -> {
            chain.add(WebIdentityTokenFileCredentialsProvider.create());
            return null;
        });

        chain.add(InstanceProfileCredentialsProvider.create());

        if (StringUtils.isNotBlank(profilePath) && StringUtils.isNotBlank(profileName)) {
            addProviderToChain(__ -> {
                chain.add(ProfileCredentialsProvider.builder()
                    .profileName(profileName)
                    .profileFile(ProfileFile.builder().content(Path.of(profilePath)).build())
                    .build());
                return null;
            });
        }
        addProviderToChain(__ -> {
            chain.add(SystemPropertyCredentialsProvider.create());
            return null;
        });

        addProviderToChain(__ -> {
            chain.add(EnvironmentVariableCredentialsProvider.create());
            return null;
        });

        if (StringUtils.isNotBlank(credentialAccessKey) && StringUtils.isNotBlank(credentialSecretKey)) {
            addProviderToChain(__ -> {
                val resolver = SpringExpressionLanguageValueResolver.getInstance();
                val credentials = AwsBasicCredentials.create(resolver.resolve(credentialAccessKey), resolver.resolve(credentialSecretKey));
                chain.add(StaticCredentialsProvider.create(credentials));
                return null;
            });
        }

        addProviderToChain(__ -> {
            chain.add(ContainerCredentialsProvider.builder().build());
            return null;
        });

        addProviderToChain(__ -> {
            chain.add(InstanceProfileCredentialsProvider.builder().build());
            return null;
        });

        LOGGER.debug("AWS chained credential providers are configured as [{}]", chain);
        return AwsCredentialsProviderChain.builder().credentialsProviders(chain).build();
    }
Gets instance.

@param credentialAccessKey the credential access key
@param credentialSecretKey the credential secret key
@param profilePath         the profile path
@param profileName         the profile name
@return the instance
support/cas-server-support-aws/src/main/java/org/apereo/cas/aws/ChainingAWSCredentialsProvider.java