getmoto / moto

A library that allows you to easily mock out tests based on AWS infrastructure.
http://docs.getmoto.org/en/latest/
Apache License 2.0
7.65k stars 2.05k forks source link

instance metadata tied direct to core model #231

Closed joekiller closed 9 years ago

joekiller commented 10 years ago

Currently moto has internal EC2 metadata included in its core model (https://github.com/spulec/moto/blob/eedb4c4b738c01642f00628b1de2827d03fc5209/moto/core/models.py#L46). This has a bad side effect where if a user is using ec2 moto mocks, instance metadata responses from external requests calls are intercepted by moto and return successfully.

This is a problem as sometimes times the code might be outside an ec2 instance when making boto calls and expect the metadata call to fail with a ConnectionError (from requests for example).

It should be considered to make metadata its own mock service as it really isn't an EC2 service so much as a feature of an EC2 instance.

Thoughts?

spulec commented 10 years ago

I understand where you are coming from, but I'm worried about what the consequences would be for the interface and backwards compatibility. Let me think it through a bit and see if I can come up with something.

joekiller commented 10 years ago

I got around it by registering the connection and them monkey patching the request to just throw a ConnectionTimeout.

spulec commented 9 years ago

Sounds good