-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
moto fails to mock newer boto resulting in AWS being accessed even if boto3.setup_default_session used #2118
Comments
After reproducing your issue in an isolated Docker container ( Could you try reinstalling moto from git?
|
@kgutwin Yes, the master fixes the problem - the test above passes successfully. Can someone shed some light on ETA of the next moto release? Maybe it's time for a beta release at least? |
@kgutwin - that's strange... on another machine (also OSX) version of moto just right from git does not fix the problem. I assume that some other dependencies may interfere? On dockerized version of this test it works, but when I modify the code to use SQS (
So, even moto master has still problems with accessing AWS - this time for SQS and probably some other services, too. |
Moto on pypi hasn't been updated in quite awhile: https://pypi.org/project/moto/#history :( edit: Looks like that was fixed. Thanks! |
Is Moto dead? The last few months have really been rough, and mocking AWS stuff is becoming miserable. Credit where credit is due of course (AWS changing everything) - what do we do? Needing to use the deprecated decorators to prevent network access is salt in the wound. |
localstack has also been rough lately. both projects need some fresh blood, sweat and tears. |
Same issue with moto 1.3.8 and with these boto versions:
|
@aizelauna I solved it using
Installing via commit till moto>1.3.8 |
thanks a lot for the information! |
Unfortunately, moto declares that it is compatible with botocore 1.12.86 and above which prevents a tool like poetry to resolve dependencies... And no override option is available to fix this case: python-poetry/poetry#697 |
A new release has been cut. Feel free to open an issue if there are still problems. |
I can still reproduce the issue with S3 and SQS tests on |
I am also still seeing this issue on
|
Is it the same code as above that is failing or something different? The above code passes for me on the latest commit in moto master branch and |
I see the error |
Are you using the decorators or server-mode? Can you add the code you are using? |
I'm using server-mode. I have a discrete process that runs outside a test suite and needs AWS services pre-seeded with data for the mock test. It's code from work so I can get you a snippet on Monday. I'm mocking S3. |
Got it. With server-mode, you will need to configure the client to point at your server. Near the end of this, we show how to do it either through the config or through passing an |
Yup, using pipenv run moto_server s3 -p ${mocks3_port} &
MOTOSERVER_PID=$!
# Moto is sort of broken right now and does not stop Boto3 from failing if AWS env creds do not exist, even if
# moto doesn't actually use them.
AWS_ACCESS_KEY_ID='1111' AWS_SECRET_ACCESS_KEY='2222' pipenv run python ${PWD}/library/test/seed_s3.py <flags, redacted> -e "${mocks3_endpoint}" The python code: s3_client = boto3.client(service_name='s3', endpoint_url=s3_url)
s3_client.create_bucket(Bucket=s3_bucket)
[seed_values(path, path_metadata, s3_bucket, s3_namespace, s3_client) for path, path_metadata in to_examine] This works fine with Moto with the manual inclusion of fake
My understanding is that moto is supposed to inject fake creds for boto3 to be satisfied. You know what, this seems slightly different than the error from the issue, although both get the credentials error. Let me know if you'd like me to file a separate issue. |
Got it. So, this is actually expected behavior. In the standalone server mode, moto has no influence over the client. Think of the server as a fake AWS web server. You are responsible for configuring the client to point at that server and any other requirements. In non-server mode, we have the ability to change the client accordingly because the decorator gives us that access. In server mode though, we have no ability to modify the client since the moto code isn't being run. |
Ahh, good to know! There may be an opportunity to make that clearer in the docs. |
Yes, we could definitely be clearer in the docs. I'll take a look. Thanks! |
This is a consequence of my comment to #2076. Here is the minimal sample code to demonstrate that moto may not mocking everything that is necessary to stop boto from reaching AWS.
s3_test.py:
requirements.txt:
To run the test pls execute:
python3 -m unittest discover -s . -p "*_test.py"
.The result as I see is:
botocore.errorfactory.BucketAlreadyExists: An error occurred (BucketAlreadyExists) when calling the CreateBucket operation: The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.
But if you don't have AWS auth in the environment the error will be:
botocore.exceptions.NoCredentialsError: Unable to locate credentials
The code above worked perfectly when using moto 1.3.7, boto3 1.7.84 and botocore 1.10.84 (the same was stated in this issue: #1815), for anything newer of boto causes moto to fail to mock properly. I've just spotted #1793 - very similar code sample and exactly the same problems.
The text was updated successfully, but these errors were encountered: