lefebsy commented on code in PR #389: URL: https://github.com/apache/polaris/pull/389#discussion_r1813159130
########## polaris-core/src/main/java/org/apache/polaris/core/storage/s3/S3CredentialsStorageIntegration.java: ########## @@ -0,0 +1,138 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.core.storage.s3; + +import java.net.URI; +import java.util.EnumMap; +import java.util.Set; +import org.apache.polaris.core.PolarisDiagnostics; +import org.apache.polaris.core.storage.InMemoryStorageIntegration; +import org.apache.polaris.core.storage.PolarisCredentialProperty; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; +import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; +import software.amazon.awssdk.regions.Region; +import software.amazon.awssdk.services.sts.StsClient; +import software.amazon.awssdk.services.sts.StsClientBuilder; +import software.amazon.awssdk.services.sts.model.AssumeRoleRequest; +import software.amazon.awssdk.services.sts.model.AssumeRoleResponse; + +/** Credential vendor that supports generating */ +public class S3CredentialsStorageIntegration + extends InMemoryStorageIntegration<S3StorageConfigurationInfo> { + + private static final Logger LOGGER = + LoggerFactory.getLogger(S3CredentialsStorageIntegration.class); + + private StsClient stsClient; + + // Constructor + public S3CredentialsStorageIntegration() { + super(S3CredentialsStorageIntegration.class.getName()); + } + + public void createStsClient(S3StorageConfigurationInfo s3storageConfig) { + + LOGGER.debug("S3Compatible - createStsClient()"); + + LOGGER.info( + "S3Compatible - AWS STS endpoint is unique and different from the S3 Endpoint. AWS SDK need to be overided with dedicated Endpoint from S3Compatible, otherwise the AWS STS url is targeted"); + + StsClientBuilder stsBuilder = software.amazon.awssdk.services.sts.StsClient.builder(); + + stsBuilder.region( + Region + .US_WEST_1); // default region to avoid bug, because most (all?) S3 compatible softwares Review Comment: Correct. It could logically be used with any S3, AWS included. The name is maybe a bad compromise, I agree to change for a better one. At the beginning I have named it s3compat.... but at the end simply s3. This choice is the result of this two constatations : - In core/storage folder the classes are named aws, gcp and azure - But in Enum Storage Type AWS is directly named S3.... So I found in enum this S3_COMPATIBILITY compromise. MinIO use it... For the class I shortened it to S3 because it could works with AWS too. I can come back to S3compat everywhere... If Enum Storage was different and aws implementation named also AWS like GCP & Azure.... but it is not. -- 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]
