List of usage examples for com.amazonaws.services.secretsmanager.model ResourceNotFoundException getMessage
@Override
public String getMessage()
From source file:com.streamsets.datacollector.credential.aws.secrets.manager.AWSSecretsManagerCredentialStore.java
License:Apache License
@Override public List<ConfigIssue> init(Context context) { List<ConfigIssue> issues = new ArrayList<>(); nameKeySeparator = context.getConfig(NAME_KEY_SEPARATOR_PROP); if (nameKeySeparator == null) { nameKeySeparator = NAME_KEY_SEPARTOR_DEFAULT; }/*from w ww . j ava 2 s. c o m*/ String region = context.getConfig(AWS_REGION_PROP); if (region == null || region.isEmpty()) { issues.add(context.createConfigIssue(Errors.AWS_SECRETS_MANAGER_CRED_STORE_00, AWS_REGION_PROP)); } String accessKey = context.getConfig(AWS_ACCESS_KEY_PROP); if (accessKey == null || accessKey.isEmpty()) { issues.add(context.createConfigIssue(Errors.AWS_SECRETS_MANAGER_CRED_STORE_00, AWS_ACCESS_KEY_PROP)); } String secretKey = context.getConfig(AWS_SECRET_KEY_PROP); if (secretKey == null || secretKey.isEmpty()) { issues.add(context.createConfigIssue(Errors.AWS_SECRETS_MANAGER_CRED_STORE_00, AWS_SECRET_KEY_PROP)); } String cacheSizeStr = context.getConfig(CACHE_MAX_SIZE_PROP); int cacheSize = (cacheSizeStr != null) ? Integer.parseInt(cacheSizeStr) : SecretCacheConfiguration.DEFAULT_MAX_CACHE_SIZE; String cacheTTLStr = context.getConfig(CACHE_TTL_MILLIS_PROP); long cacheTTL = (cacheTTLStr != null) ? Integer.parseInt(cacheTTLStr) : SecretCacheConfiguration.DEFAULT_CACHE_ITEM_TTL; if (issues.isEmpty()) { LOG.debug("Creating Secret Cache for region '{}'", region); secretCache = createSecretCache(accessKey, secretKey, region, cacheSize, cacheTTL); // Verify we can connect try { secretCache.getSecretString("test-AWSSecretsManagerCredentialStore"); } catch (ResourceNotFoundException ex) { // expected: ignore } catch (Exception ex) { LOG.error(Errors.AWS_SECRETS_MANAGER_CRED_STORE_01.getMessage(), ex.getMessage(), ex); issues.add( context.createConfigIssue(Errors.AWS_SECRETS_MANAGER_CRED_STORE_01, ex.getMessage(), ex)); } } return issues; }