-
-
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 1.3.8 breaks real boto3 access #2172
Comments
I did a quick check for S3 API access and get a similar failure with an |
I have a similar issue. It seems like importing the moto module prevents normal aws usage. This works: import boto3
from moto import mock_s3
@mock_s3
def test():
conn = boto3.resource('s3', region_name='us-east-1')
conn.create_bucket(Bucket='a-totally-unique-moto-bucket-name')
test() This also works (no moto at all) import boto3
#from moto import mock_s3
#@mock_s3
def test():
conn = boto3.resource('s3', region_name='us-east-1')
conn.create_bucket(Bucket='a-totally-unique-moto-bucket-name')
test() But this throws an InvalidAccessKeyId error: import boto3
from moto import mock_s3
#@mock_s3
def test():
conn = boto3.resource('s3', region_name='us-east-1')
conn.create_bucket(Bucket='a-totally-unique-moto-bucket-name')
test() botocore.exceptions.ClientError: An error occurred (InvalidAccessKeyId) when calling the CreateBucket operation: The AWS Access Key Id you provided does not exist in our records. |
It also breaks real boto (2) access. I believe the root cause is this commit - cf5bd76, setting 2 env variables (AWS_ACCESS_KEY_ID , AWS_SECRET_ACCESS_KEY) in moto/core/models.py. They can impact boto connection initialization on every flow running after the models.py is imported. This works fine:
While this breaks:
|
+1 Also being impacted by this issue, behavior is consistent with what others have described |
+1 Currently have to place tests that import moto into a different directory and execute them separately to get around this. Would be great to run them as part of the same test execution. |
Can someone please try the PR here? #2285 |
@spulec Tried and it works perfectly. Looking forward to it being merged. Thank you! |
Great. I've merged it: #2285 |
@ch3ck It has been released in a pre-release https://pypi.org/project/moto/#history . You could use it for now. |
@ch3ck Still not released to PyPi, I'm using a horrible workaround but it works: import moto inside the fixture definition. I only have one for now and it's not breaking my code, so I'll stick to it until a stable release. |
@danielcarletti as noted in the above comment, we have prereleases on every commit. Are those not working for you? |
Pre-release packages are fine, but then I have to pin that specific version. Is there any plan for when the next official release is expected? I would like to keep just |
|
I have moto installed and updated regularly with lots of other packages as part of many Python projects. I think it is a normal expectation that packages do stable releases at some periodic frequency. Specifically installing a pre-release would not be part of such a normal process. Just looking to know when the next stable release is for moto. I love the capabilities of moto and I look forward to the next official release. |
Sorry for my admittedly terse response.
I've been having discussions with various people and trying to really understand the value of this for Moto. Unlike a normal package, we are always adding new endpoints/resources. When we cut releases, there isn't anything additional that is done to ensure it is "stable". The releases aren't any different than the prereleases. I'll work to cut a release in the next couple days, but I do think our current process is broken. I'm tempted to either have every commit make a real release or do something like pytz and have monthly releases (we would automate them). My fear with both of these is giving a false sense of security to people. Thoughts? |
I would suggest that they are all official releases then. I agree that a monthly "official" release would present a false sense of stability of the release. The |
This seems like the root of the issue here, regardless of when releases are. Does it make sense to create a (small, limited) set of integration tests? Int tests can pull the latest dev version, and verify that real life use-cases (like the ones above) still work. With regards to automated releases (regardless of the frequency) :
Cutting manual releases is admittedly more work - but does get around these two issues, and as long as integration tests are run manually it also ensures release stability. |
Just installed the latest 1.3.8 release and it appears to have broken my tests that make actual non-mocked STS calls when the test file includes moto. I've narrowed down the issue and created a minimal example to show the problem.
Test code in file
moto38.py
:Now run the test and note the error output with exception
InvalidClientTokenId
:If I fall back to moto==1.3.7 the test gets past this error. Note that I didn't bother making the policy and role work properly, but in my tests the real values work as expected when using the previous moto version.
The text was updated successfully, but these errors were encountered: