Skip to content
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

Service endpoint_url from config file ignored #5779

Open
1 task
fkjaekel opened this issue Jan 8, 2025 · 1 comment
Open
1 task

Service endpoint_url from config file ignored #5779

fkjaekel opened this issue Jan 8, 2025 · 1 comment
Assignees
Labels
bug This issue is a bug. needs-review This issue or PR needs review from the team. p2 This is a standard priority issue

Comments

@fkjaekel
Copy link

fkjaekel commented Jan 8, 2025

Describe the bug

In order to use the least environment variables possible with localstack, I created the following profile:

[services localstack-specific]
s3 =
  endpoint_url = http://s3.localhost.localstack.cloud:4566

[profile localstack]
region = us-east-1
output = json
endpoint_url=http://localhost:4566
services = localstack-specific

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Be able to use the endpoint_url from config file instead of the AWS_ENDPOINT_URL_S3 environment variable

Current Behavior

Since the endpoint_url from config is not being used, if I don't set AWS_ENDPOINT_URL_S3 I get this at localstack:

File "/opt/code/localstack/.venv/lib/python3.11/site-packages/localstack/aws/protocol/parser.py", line 779, in _parse_xml_string_to_dom
raise ProtocolParserError(
localstack.aws.protocol.parser.ProtocolParserError: Unable to parse request (not well-formed (invalid token): line 1, column 0), invalid XML received:
b'{"sourceId":"1","eventDateTime":"2024-11-14T12:13:18.6870-03:00","code":"1 ","sourceApplicationId":1,"display":"TESTE","active":"true "}'
(Service: S3, Status Code: 500, Request ID: 4d0a9fbd-6893-4f2d-9f55-138ddb31fbd6, Extended Request ID: s9lzHYrFp76ZVxRcpX9+5cjAnEH2ROuNkd2BHfIa6UkFVdtjf5mKR3/eTPFvsiP/XV/VLi31234=)
Suppressed: software.amazon.awssdk.core.exception.SdkClientException: Request attempt 2 failure: exception while calling s3 with unknown operation: Traceback (most recent call last):
File "/opt/code/localstack/.venv/lib/python3.11/site-packages/localstack/aws/protocol/parser.py", line 776, in _parse_xml_string_to_dom
parser.feed(xml_string)
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0

Reproduction Steps

set AWS_PROFILE=localstack and use S3AsyncClient

Possible Solution

No response

Additional Information/Context

localstack version: 4

AWS Java SDK version used

2.29.47

JDK version used

openjdk version "21.0.2" 2024-01-16 OpenJDK Runtime Environment GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30) OpenJDK 64-Bit Server VM GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30, mixed mode, sharing)

Operating System and version

Linux Mint 22

@fkjaekel fkjaekel added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 8, 2025
@bhoradc bhoradc added needs-reproduction This issue needs reproduction. p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Jan 8, 2025
@bhoradc bhoradc self-assigned this Jan 8, 2025
@bhoradc bhoradc added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-reproduction This issue needs reproduction. labels Jan 8, 2025
@bhoradc
Copy link

bhoradc commented Jan 9, 2025

Hi @fkjaekel,

Thank you for bringing this issue to our attention. I am able to reproduce the scenario with AWS S3.

Support for service-specific endpoints was introduced in Java SDK version 2.28.1. I have observed that the service-specific endpoint configuration under the services section has not been working correctly since then. I have validated this behavior with the latest SDK version (2.29.48) as well.

  • Reproducible code sample:
package org.example;

import software.amazon.awssdk.core.async.AsyncRequestBody;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3AsyncClient;
import software.amazon.awssdk.services.s3.model.PutObjectRequest;
import software.amazon.awssdk.services.s3.model.PutObjectResponse;
import java.nio.file.Paths;
import java.util.concurrent.CompletableFuture;

public class Main {
    public static void main(String[] args) {
        S3AsyncClient s3AsyncClient = S3AsyncClient.builder()
                .region(Region.US_EAST_1)
                .build();
        String bucketName = "***";
        String key = "***.txt";
        String filePath = "/Users/***/Desktop/sampleobject.txt";
        PutObjectRequest putObjectRequest = PutObjectRequest.builder()
                .bucket(bucketName)
                .key(key)
                .build();
        CompletableFuture<PutObjectResponse> future = s3AsyncClient.putObject(
                putObjectRequest,
                AsyncRequestBody.fromFile(Paths.get(filePath))
        );
        future.whenComplete((response, error) -> {
            if (error != null) {
                System.err.println("Error uploading file: " + error.getMessage());
            } else {
                System.out.println("File uploaded successfully! ETag: " + response.eTag());
            }
            s3AsyncClient.close();
        });
        future.join();
    }
}
  • Config file:
[services s3-specific]
s3 = 
  endpoint_url = https://s3.us-east-2.amazonaws.com
[profile localstack]
region = us-east-1
output = json
services = s3-specific

I have tested and confirmed that the service-specific endpoint can be set correctly using the AWS_ENDPOINT_URL_S3 environment variable or the aws.endpointUrlS3 JVM system property. You can continue using these methods as a workaround until the issue is resolved.

I will review this issue with the team to further investigate on it.

Regards,
Chaitanya

@bhoradc bhoradc added needs-review This issue or PR needs review from the team. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-review This issue or PR needs review from the team. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

2 participants