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

Wrong selection of backend when running moto server on EC2 #2539

Closed
trickstyler opened this issue Nov 5, 2019 · 4 comments
Closed

Wrong selection of backend when running moto server on EC2 #2539

trickstyler opened this issue Nov 5, 2019 · 4 comments

Comments

@trickstyler
Copy link

I'm running moto on an EC2 VM. I got another system running also as an EC2 VM which calls moto. when trying to create a new stack (CloudFormation) i'm getting a NotImplemented Error.

After plenty of debugging - i found that moto actually infers the backend from the host name.
Reference: moto/server.py line: 121

Is there a reason for this? I'm not really sure this is true to the normal behavior of AWS

Suggestion: completely remove this check. i'd be happy to do create a PR if that's agreed.

@spulec
Copy link
Collaborator

spulec commented Nov 21, 2019

If one is running multiple backends at the same time, we need some way to know which service the user is requesting. The host header seemed like the best option available, but I'm open to alternatives.

@trickstyler
Copy link
Author

I think we should switch to the authorization header
OR
Add another custom header to the request (available via the SDK) that signals which backend you want to handle the request - could be used in cases where you run the server on an actual EC2

@spulec
Copy link
Collaborator

spulec commented Feb 18, 2020

We also look at the authorization header where possible: https://github.com/spulec/moto/blob/master/moto/server.py#L61-L102

There may be more there we can do to extend that.

I would be okay adding logic to the server to also check for another custom header. Ideally, we would follow a similar pattern as the Host header so it could be as simple a change as

host = environ["HTTP_HOST"].split(":")[0]

->

host = environ.get("HTTP_HOST", "MOTO_SERVER").split(":")[0]

@bblommers
Copy link
Collaborator

It's been a while, but this should now work as of Moto v5 - Moto no longer relies on the HTTP_HOST header.

Please see the release accouncement (with all breaking changes) here: #7198

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants