-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEAT: AWS secret extension #3340
Conversation
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
…nsion Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
…nsion Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
package org.opensearch.dataprepper.model.plugin; | ||
|
||
public interface PluginConfigValueTranslator { | ||
String translate(final String value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return a generic type as it can vary.
@@ -0,0 +1,7 @@ | |||
package org.opensearch.dataprepper.aws.api; | |||
|
|||
public interface SecretsSupplier { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to expose this in the aws-plugin-api
. It could couple plugins with AWS SecretsManager which is not desirable.
data-prepper-core/build.gradle
Outdated
@@ -16,6 +16,7 @@ dependencies { | |||
implementation project(':data-prepper-expression') | |||
implementation project(':data-prepper-plugins:blocking-buffer') | |||
implementation project(':data-prepper-plugins:common') | |||
implementation project(':data-prepper-plugins:aws-plugin') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data Prepper core should not depend on aws-plugin
. The extensions framework is what will let this load dynamically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch! It is unnecessary
@@ -16,7 +20,7 @@ jacocoTestCoverageVerification { | |||
violationRules { | |||
rule { | |||
limit { | |||
minimum = 1.0 | |||
minimum = 0.98 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What can we do to this back to 100%?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one JsonProcessingException unreachable:
@Override
public Object retrieveValue(String secretId) {
if (!secretIdToValue.containsKey(secretId)) {
throw new IllegalArgumentException(String.format("Unable to find secretId: %s", secretId));
}
try {
final Object secretValue = secretIdToValue.get(secretId);
return secretValue instanceof Map ? OBJECT_MAPPER.writeValueAsString(secretIdToValue.get(secretId)) :
secretValue;
} catch (JsonProcessingException e) {
throw new IllegalArgumentException(String.format("Unable to read the value under secretId: %s as string",
secretId));
}
}
This is about writing value back into a string when ${{aws_secrets:secretId}} is used but the actual secret Value is a valid json, which means we interpret it as literal value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you mock secretIdToValue
such that get(secretId)
returns non-JSON?
private static final String AWS_IAM_ROLE = "role"; | ||
private static final String AWS_IAM = "iam"; | ||
|
||
@JsonProperty("name") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AWS SecretsManager uses the term SecretId
, so let's name this secret_id
.
.build(); | ||
} | ||
|
||
private AwsCredentialsProvider authenticateAwsConfiguration() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the existing AWSCredentialsProvider as provided by the AWS Plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try { | ||
getSecretValueResponse = secretsManagerClient.getSecretValue(getSecretValueRequest); | ||
} catch (Exception e) { | ||
throw ResourceNotFoundException.builder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you throwing an AWS SDK exception here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to wrap it with a more explicit error message. Maybe RuntimeException is more appropriate?
@@ -78,7 +78,7 @@ public static RetryConfiguration readRetryConfig(final PluginSetting pluginSetti | |||
if (dlqFile != null) { | |||
builder = builder.withDlqFile(dlqFile); | |||
} | |||
final Integer maxRetries = (Integer) pluginSetting.getAttributeFromSettings(MAX_RETRIES); | |||
final Integer maxRetries = pluginSetting.getIntegerOrDefault(MAX_RETRIES, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these part of another PR? This seems unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting would not work for secret value substitution especially when it is a String. But it is possible with generic type in PluginConfigValueTranslator this would not be necessary
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Description
This PR adds support for AWS secret extension plugin:
The scope of settings that support secret reference is limited to plugins (source/buffer/sink/processor) in pipeline.YAML. The reference pattern is explained as follows:
username
in the secret jsonIssues Resolved
Resolves #2780
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.