Closed joekiller closed 9 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.
I got around it by registering the connection and them monkey patching the request to just throw a ConnectionTimeout.
Sounds good
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?