localstack / localstack/localstack-python-client

[Feature] Support virtual host S3 API calls

Ouverte
#52 0 commentaires 1 réaction 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
Python
Étoiles
191
Forks
31
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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://.:`. This is not a valid endpoint, and it should be `http://.s3.:`, as described [here](https://docs.localstack.cloud/user-guide/aws/s3/#path-style-and-virtual-hosted-style-requests).

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

```python3
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?

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par lire localstack_client.config.get_endpoint et get_service_endpoints, puis reproduisez la requête S3 avec la journalisation de débogage de boto3 et Docker Compose. Examinez les indications relatives aux endpoints dans README.md et déterminez laquelle des trois approches proposées le projet devrait adopter ; done doit inclure une voie d’adressage virtual-host définie et fonctionnelle, ainsi que la documentation correspondante.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
aws, python
Domaine
api, cloud
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
30/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.