question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow mock_s3 to use the standalone moto server

See original GitHub issue

Long story short, I need to run the standalone moto server for pyspark to be able to access files, but I would like to use the same server for the internal calls happening on the python side using boto3.

The solution for changing the endpoint_url per every Session created isn’t feasible for me and having to add a .boto config file is also complicated as I don’t want to keep writing and erasing files and potentially have a broken env.

If boto were to implement something like this: https://github.com/boto/boto3/pull/2746 it would be very simple to setup the environment variable, but seems like they aren’t willing to.

Then another solution would seem the best which is allow mock_s3 (or any service mock) decorator to get a parameter and point to original mock server such as

@mock_s3(url='http://localhost:5000')
def test_foo(self):
    s3 = boto3.client('s3')
    s3.download_file(....)

Background info: https://github.com/spulec/moto/issues/1543 https://github.com/boto/boto3/issues/1375

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
bblommerscommented, Oct 15, 2021

Our documentation is… a work in progress, let’s put it like that. 🙂 Let me know if you have any other questions. I’ll leave this issue open anyway as a reminder to myself to improve the docs in this area.

0reactions
jbvsmocommented, Oct 15, 2021

Seems like you have many hidden secrets! (Or I can’t read docs)

It appears to be working for the initial thing I’m trying. I will do further testing. Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Started with Moto — Moto 4.0.13.dev documentation
You can use pip to install the latest released version of moto ... Moto also comes with a stand-alone server allowing you to...
Read more >
Moto Documentation - Read the Docs
Moto has a stand-alone server mode. This allows you to use Moto with any of the official AWS SDK's. 2.2.1 Installation.
Read more >
Moto mock_s3 EndpointConnectionError, Connection refused
The problem was that i specified an endpoint in the resource call: self.s3_resource = boto3.resource( "s3", endpoint_url=endpoint, ...
Read more >
How to use the moto.server.create_backend_app function in ...
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >
How to test your AWS code using Moto and Pytest - Learn AWS
In this article, we will look at how we can use Moto, which is a Python library ... Let's create such a file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found