localstack / localstack/localstack-python-client

[Feature] Support virtual host S3 API calls

Aberta
#52 0 comentários 1 reação 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Linguagem predominante
Python
Estrelas
191
Forks
31
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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?

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece lendo localstack_client.config.get_endpoint e get_service_endpoints; em seguida, reproduza a requisição S3 com o registro de depuração do boto3 e o Docker Compose. Revise as orientações sobre endpoints no README.md e determine qual das três abordagens propostas o projeto deve adotar; done deve incluir um caminho de virtual-host addressing decidido e funcional, além da documentação correspondente.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
aws, python
Domínio
api, cloud
Tipo de issue
Funcionalidade
Dificuldade
5/5
Tempo estimado
Mais de uma semana
Status de atividade
Estagnada
Clareza
Precisa de esclarecimento
Facilidade para iniciantes
30/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.