From fd5cadc60d53e6482d7366bee2e9577470b4946d Mon Sep 17 00:00:00 2001 From: David Turanski Date: Wed, 9 Sep 2020 18:26:20 -0400 Subject: [PATCH] Add use-path-style-access to AmazonS3Properties --- applications/sink/s3-sink/README.adoc | 1 + applications/source/s3-source/README.adoc | 1 + .../cloud/fn/common/aws/s3/AmazonS3Properties.java | 14 ++++++++++++++ .../s3/CompatibleStorageAmazonS3Configuration.java | 1 + 4 files changed, 17 insertions(+) diff --git a/applications/sink/s3-sink/README.adoc b/applications/sink/s3-sink/README.adoc index a01f3150..0423f242 100644 --- a/applications/sink/s3-sink/README.adoc +++ b/applications/sink/s3-sink/README.adoc @@ -16,6 +16,7 @@ The **$$s3$$** $$sink$$ has the following options: //tag::configuration-properties[] $$s3.common.endpoint-url$$:: $$Optional endpoint url to connect to s3 compatible storage.$$ *($$String$$, default: `$$$$`)* +$$s3.common.path-style-access$$:: $$Use path style access.$$ *($$Boolean$$, default: `$$false$$`)* $$s3.consumer.acl$$:: $$S3 Object access control list.$$ *($$CannedAccessControlList$$, default: `$$$$`, possible values: `private`,`public-read`,`public-read-write`,`authenticated-read`,`log-delivery-write`,`bucket-owner-read`,`bucket-owner-full-control`,`aws-exec-read`)* $$s3.consumer.acl-expression$$:: $$Expression to evaluate S3 Object access control list.$$ *($$Expression$$, default: `$$$$`)* $$s3.consumer.bucket$$:: $$AWS bucket for target file(s) to store.$$ *($$String$$, default: `$$$$`)* diff --git a/applications/source/s3-source/README.adoc b/applications/source/s3-source/README.adoc index 79ada24a..d2415188 100644 --- a/applications/source/s3-source/README.adoc +++ b/applications/source/s3-source/README.adoc @@ -54,6 +54,7 @@ $$file.consumer.markers-json$$:: $$When 'fileMarkers == true', specify if they s $$file.consumer.mode$$:: $$The FileReadingMode to use for file reading sources. Values are 'ref' - The File object, 'lines' - a message per line, or 'contents' - the contents as bytes.$$ *($$FileReadingMode$$, default: `$$$$`, possible values: `ref`,`lines`,`contents`)* $$file.consumer.with-markers$$:: $$Set to true to emit start of file/end of file marker messages before/after the data. Only valid with FileReadingMode 'lines'.$$ *($$Boolean$$, default: `$$$$`)* $$s3.common.endpoint-url$$:: $$Optional endpoint url to connect to s3 compatible storage.$$ *($$String$$, default: `$$$$`)* +$$s3.common.path-style-access$$:: $$Use path style access.$$ *($$Boolean$$, default: `$$false$$`)* $$s3.supplier.auto-create-local-dir$$:: $$Create or not the local directory.$$ *($$Boolean$$, default: `$$true$$`)* $$s3.supplier.delete-remote-files$$:: $$Delete or not remote files after processing.$$ *($$Boolean$$, default: `$$false$$`)* $$s3.supplier.filename-pattern$$:: $$The pattern to filter remote files.$$ *($$String$$, default: `$$$$`)* diff --git a/functions/common/aws-s3-common/src/main/java/org/springframework/cloud/fn/common/aws/s3/AmazonS3Properties.java b/functions/common/aws-s3-common/src/main/java/org/springframework/cloud/fn/common/aws/s3/AmazonS3Properties.java index 6409eb5e..b954fcb7 100644 --- a/functions/common/aws-s3-common/src/main/java/org/springframework/cloud/fn/common/aws/s3/AmazonS3Properties.java +++ b/functions/common/aws-s3-common/src/main/java/org/springframework/cloud/fn/common/aws/s3/AmazonS3Properties.java @@ -20,6 +20,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; /** * @author Timo Salm + * @author David Turanski */ @ConfigurationProperties("s3.common") public class AmazonS3Properties { @@ -29,6 +30,19 @@ public class AmazonS3Properties { */ private String endpointUrl; + /** + * Use path style access. + */ + private boolean pathStyleAccess; + + public boolean isPathStyleAccess() { + return pathStyleAccess; + } + + public void setPathStyleAccess(boolean pathStyleAccess) { + this.pathStyleAccess = pathStyleAccess; + } + public String getEndpointUrl() { return this.endpointUrl; } diff --git a/functions/common/aws-s3-common/src/main/java/org/springframework/cloud/fn/common/aws/s3/CompatibleStorageAmazonS3Configuration.java b/functions/common/aws-s3-common/src/main/java/org/springframework/cloud/fn/common/aws/s3/CompatibleStorageAmazonS3Configuration.java index cdbdab91..efaac3ac 100644 --- a/functions/common/aws-s3-common/src/main/java/org/springframework/cloud/fn/common/aws/s3/CompatibleStorageAmazonS3Configuration.java +++ b/functions/common/aws-s3-common/src/main/java/org/springframework/cloud/fn/common/aws/s3/CompatibleStorageAmazonS3Configuration.java @@ -46,6 +46,7 @@ public class CompatibleStorageAmazonS3Configuration { builder.setEndpointConfiguration(endpointConfiguration); return builder .withCredentials(awsCredentialsProvider) + .withPathStyleAccessEnabled(amazonS3Properties.isPathStyleAccess()) .build(); } }