You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/01/03 13:26:00 UTC

[jira] [Work logged] (BEAM-13587) Use AwsRegionProvider to load region in AwsOptions if available

     [ https://issues.apache.org/jira/browse/BEAM-13587?focusedWorklogId=702931&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-702931 ]

ASF GitHub Bot logged work on BEAM-13587:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Jan/22 13:25
            Start Date: 03/Jan/22 13:25
    Worklog Time Spent: 10m 
      Work Description: aromanenko-dev commented on a change in pull request #16405:
URL: https://github.com/apache/beam/pull/16405#discussion_r777474322



##########
File path: sdks/java/io/amazon-web-services/src/main/java/org/apache/beam/sdk/io/aws/options/AwsOptions.java
##########
@@ -33,11 +34,23 @@
 
   /** AWS region used by the AWS client. */
   @Description("AWS region used by the AWS client")
-  @Validation.Required
+  @Default.InstanceFactory(AwsRegionFactory.class)
   String getAwsRegion();
 
   void setAwsRegion(String value);
 
+  /** Attempt to load default region. */
+  class AwsRegionFactory implements DefaultValueFactory<String> {
+    @Override
+    public String create(PipelineOptions options) {
+      try {
+        return new DefaultAwsRegionProviderChain().getRegion();
+      } catch (SdkClientException e) {
+        return null;

Review comment:
       Should we print out an error here? Can it cause NPE later?

##########
File path: sdks/java/io/amazon-web-services/src/main/java/org/apache/beam/sdk/io/aws/options/AwsOptions.java
##########
@@ -33,11 +34,23 @@
 
   /** AWS region used by the AWS client. */
   @Description("AWS region used by the AWS client")
-  @Validation.Required
+  @Default.InstanceFactory(AwsRegionFactory.class)
   String getAwsRegion();
 
   void setAwsRegion(String value);
 
+  /** Attempt to load default region. */
+  class AwsRegionFactory implements DefaultValueFactory<String> {
+    @Override
+    public String create(PipelineOptions options) {
+      try {
+        return new DefaultAwsRegionProviderChain().getRegion();
+      } catch (SdkClientException e) {
+        return null;

Review comment:
       Should we print out an error here? 
   Can it cause NPE later?




-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 702931)
    Time Spent: 0.5h  (was: 20m)

> Use AwsRegionProvider to load region in AwsOptions if available
> ---------------------------------------------------------------
>
>                 Key: BEAM-13587
>                 URL: https://issues.apache.org/jira/browse/BEAM-13587
>             Project: Beam
>          Issue Type: Improvement
>          Components: io-java-aws
>            Reporter: Moritz Mack
>            Assignee: Moritz Mack
>            Priority: P2
>              Labels: aws-sdk-v1, aws-sdk-v2, s3
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.20.1#820001)