All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.linguarobot.aws.cdk.maven.AccountCredentialsProviderChain Maven / Gradle / Ivy

Go to download

The AWS CDK Maven plugin produces and deploys CloudFormation templates based on the cloud infrastructure defined by means of CDK. The goal of the project is to improve the experience of Java developers while working with CDK by eliminating the need for installing Node.js and interacting with the CDK application by means of CDK Toolkit.

There is a newer version: 0.0.8
Show newest version
package io.linguarobot.aws.cdk.maven;

import io.linguarobot.aws.cdk.maven.api.AccountCredentialsProvider;
import software.amazon.awssdk.auth.credentials.AwsCredentials;

import java.util.List;
import java.util.Optional;

/**
 * Composite {@link AccountCredentialsProvider} that sequentially delegates to a chain of providers looking in order
 * to find {@link AwsCredentials} for the account.
 */
public class AccountCredentialsProviderChain implements AccountCredentialsProvider {

    private final List credentialsProviders;

    public AccountCredentialsProviderChain(List credentialsProviders) {
        this.credentialsProviders = credentialsProviders;
    }

    @Override
    public Optional get(String accountId) {
        return credentialsProviders.stream()
                .map(credentialsProvider -> credentialsProvider.get(accountId))
                .filter(Optional::isPresent)
                .map(Optional::get)
                .findAny();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy