Moto: Question about moto and boto3 region

Created on 2 Sep 2020  路  2Comments  路  Source: spulec/moto

Question

Hello moto community,

I was looking for a place to ask a question regading a behaviour of moto, to know if it is normal and to get more information about it.

So regarding the boto3 region we give it during instanciation, how is this region taken into account ?

  • For the case of the new aws chinese region (that is not integrated yet), we tested moto with that region and it did not seem to raise an error for "mocking not possible" but rather execute boto3 real endpoints and creating resources on the cloud ... Is this an intended behavior for moto and are there other cases where boto3 aws endpoints are called and not the mocks ?
  • Is moto mocking aws services per region (with api differences between regions) ? All i can find for now a state per service so i would guess that all mocked services are with the "same version"..

Thank you for you time and good job with the project

Lamine

Version of packages tested :
python==3.7
moto== 1.3.14
pytest==5.3.2
pytest-env==0.6.2
pytest-cov==2.7.1
boto==1.12.13

question

All 2 comments

Hi @Lamine34,

1) The behaviour to call real endpoints was the intended behaviour on moto 1.3.14, where it would only intercept known services/endpoints/regions.
Considering this is quite dangerous, we switched away from this now, and the latest dev-releases intercept every call to *amazonaws.com. When calling an unknown service/endpoint/region, it will throw an NotImplementedError.
(See https://pypi.org/project/moto/#history for the latest release.)

Similarly, in 1.3.14 we only supported a fixed list of regions.
The latest releases support all regions that are known to boto, so as long as boto is up to date, Chinese regions should be supported.

2) Moto instantiates a separate class per service per region, to ensure that the data is logically separated. So all regions have the same functionality/behaviour.

Hope that helps.

Hello bblommers,

Thank you for your quick reply, it is perfectly clear. I was looking for a confirmation of what we observed,

I agree that it is safer to raise "NotImplementedError", this is important especially for production integration pipelines like in our use case where this "shady" behaviour can be a little painful to understand.

I'm happy that the project is taking this path for its future,

Good luck for everything and untill next time

Lamine

Was this page helpful?
0 / 5 - 0 ratings