Skip to content
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

Mock region #4252

Closed
sebstepien opened this issue Sep 1, 2021 · 4 comments · Fixed by #4699
Closed

Mock region #4252

sebstepien opened this issue Sep 1, 2021 · 4 comments · Fixed by #4699

Comments

@sebstepien
Copy link

Can you allow mock regions in the mocks?
I have this set
os.environ['AWS_DEFAULT_REGION'] = 'any-region'

and error it produces:

E       KeyError: 'any-region'
../../../.local/lib/python3.8/site-packages/moto/dynamodb2/responses.py:79: KeyError
@bblommers
Copy link
Collaborator

Hi @As1s! Technically it should be possible to support this. If you don't mind me asking - what's the reasoning behind having a non-existent region?

@sebstepien
Copy link
Author

Extra level of protection so that tests do not write to the real environment.

@bblommers
Copy link
Collaborator

Ah, gotcha, that makes sense. The current implementation acts as a validation in itself, to verify that the specified region is correct/supported, and it would be good to keep that.

I'll mark it as an enhancement to implement it in a way that doesn't break this behaviour:

os.environ['MOTO_ALLOW_NONEXISTENT_REGION'] = True # defaults to False
os.environ['AWS_DEFAULT_REGION'] = 'any-region'

@sebstepien
Copy link
Author

Also in your Pytest usage example it would be good to show set up of default region env var in the credentials fixture.
Often region in lambda code is not specified when creating client and uses default region.
I hope this makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants