localstack / localstack/localstack-python-client

[Feature] Support virtual host S3 API calls

Đang mở
#52 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Python
Star
191
Fork
31
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

After struggling for several hours with Docker Compose, I noticed my problem was actually in this library, which does not seem to support the virtual host addressing for the s3 client.

Looking at boto3 in debug mode, I noticed that when using Virtual host addressing, the HTTP request was aimed towards http://<bucket>.<endpoint_url>:<endpoint_port>. This is not a valid endpoint, and it should be http://<bucket>.s3.<endpoint_url>:<endpoint_port>, as described here.

After delving deeper I noticed localstack_client.config.get_endpoint it is not handling s3 in any special way. I manually patched the function and noticed that with a simple

def new_get_service_endpoint(
        service: str, localstack_host: Optional[str] = None
    ) -> Optional[str]:
        endpoints = localstack_client.config.get_service_endpoints(localstack_host=localstack_host)
        endpoint = endpoints.get(service)
        if service == "s3":
            endpoint = "http://s3." + endpoint.split("http://")[1]
        return endpoint

I know this doesn't handle SSL, it's just a draft. It works for both virtual and path based addressing.

I see three ways simple about this:

  1. Do not support virtual host addressing. This is a problem, as in theory AWS is deprecating path based addressing (also it has been deprecating it for 4 years, so...)
  2. Do a hack like the one proposed.
  3. Honor AWS service specific endpoints through envars (for instance AWS_ENDPOINT_URL_S3) and leave it up to the user to set it up (with appropriate documentation, at least in the README.md).

What are your thoughts on this?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách đọc localstack_client.config.get_endpoint và get_service_endpoints, sau đó tái hiện yêu cầu S3 bằng ghi nhật ký gỡ lỗi của boto3 và Docker Compose. Xem lại hướng dẫn về endpoint trong README.md và xác định dự án nên áp dụng phương án nào trong ba phương án được đề xuất; done phải bao gồm một hướng virtual-host addressing đã được quyết định và hoạt động, cùng với tài liệu tương ứng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
aws, python
Lĩnh vực
api, cloud
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.