shunping commented on code in PR #41130:
URL: https://github.com/apache/beam/pull/41130#discussion_r4517264608


##########
sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/options/AwsModule.java:
##########
@@ -204,12 +206,28 @@ public AwsCredentialsProvider deserializeWithType(
                     .orElse(
                         
StsAssumeRoleForFederatedCredentialsProvider.DEFAULT_SESSION_DURATION_SECS))
             .build();
+      } else if 
(typeName.equals(SecretCredentialsProvider.class.getSimpleName())) {
+        return SecretCredentialsProvider.create(
+            getNotNull(json, SECRET_MANAGER, typeName),
+            getSpec(json, ACCESS_KEY_ID, typeName),
+            getSpec(json, SECRET_ACCESS_KEY, typeName),
+            json.has(SESSION_TOKEN) ? getSpec(json, SESSION_TOKEN, typeName) : 
null);
       } else {
         throw new IOException(
             String.format("AWS credential provider type '%s' is not 
supported", typeName));
       }
     }
 
+    /**
+     * Returns a secret spec, which may be given as a JSON string or, to avoid 
escaping, as a JSON
+     * object.
+     */
+    private String getSpec(JsonNode json, String key, String typeName) {
+      JsonNode node = json.get(key);
+      checkNotNull(node, "AWS credentials provider type '%s' is missing '%s'", 
typeName, key);
+      return node.isTextual() ? node.textValue() : node.toString();

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to