Search in sources :

Example 1 with AwsSecretsManagerPropertySource

use of io.awspring.cloud.secretsmanager.AwsSecretsManagerPropertySource in project spring-cloud-aws by awspring.

the class AwsSecretsManagerConfigDataLoader method load.

@Override
public ConfigData load(ConfigDataLoaderContext context, AwsSecretsManagerConfigDataResource resource) {
    try {
        AWSSecretsManager sm = context.getBootstrapContext().get(AWSSecretsManager.class);
        AwsSecretsManagerPropertySource propertySource = resource.getPropertySources().createPropertySource(resource.getContext(), resource.isOptional(), sm);
        if (propertySource != null) {
            return new ConfigData(Collections.singletonList(propertySource));
        } else {
            return null;
        }
    } catch (Exception e) {
        throw new ConfigDataResourceNotFoundException(resource, e);
    }
}
Also used : AwsSecretsManagerPropertySource(io.awspring.cloud.secretsmanager.AwsSecretsManagerPropertySource) ConfigData(org.springframework.boot.context.config.ConfigData) AWSSecretsManager(com.amazonaws.services.secretsmanager.AWSSecretsManager) ConfigDataResourceNotFoundException(org.springframework.boot.context.config.ConfigDataResourceNotFoundException) ConfigDataResourceNotFoundException(org.springframework.boot.context.config.ConfigDataResourceNotFoundException)

Aggregations

AWSSecretsManager (com.amazonaws.services.secretsmanager.AWSSecretsManager)1 AwsSecretsManagerPropertySource (io.awspring.cloud.secretsmanager.AwsSecretsManagerPropertySource)1 ConfigData (org.springframework.boot.context.config.ConfigData)1 ConfigDataResourceNotFoundException (org.springframework.boot.context.config.ConfigDataResourceNotFoundException)1